老师这个tag===ts是什么意思,ts好像是文件名
老师您好,为什么这种方式导入一个类,就可以完成mysql数据参数的配置,from_object这个函数,接受了这个Config类就意味着,参数已经进来了对吗?
package com.itbaizhan; import java.sql.Connection; import java.sql.Statement; /** * Statement对象的使用 */ public class StatementTest { /** * 添加用户 */ public void insertUsers(String username,int userage){ Connection connection = null; Statement statement = null; try{ //获取Connection对象 connection = JdbcUtils.getConnection(); //获取Statement对象 statement = connection.createStatement(); //定义需要执行的SQL语句 String sql = "insert into users values(default,'"+username+"',"+userage+")"; //执行SQL,返回boolean值,如果SQL有结果集返回,那么返回值为true,如果没有结果集返回,则返回false. boolean execute = statement.execute(sql); System.out.println(execute); }catch(Exception e){ e.printStackTrace(); }finally{ JdbcUtils.closeResource(statement,connection); } } } package com.itbaizhan; import java.io.InputStream; import java.sql.*; import java.util.Properties; /** * 工具类 */ public class JdbcUtils { private static String url; private static String name; private static String pwd; static { try { //实例化Properties对象 Properties prop = new Properties(); //获取读取properties文件的字节输入流对象 InputStream is = JdbcTest2.class.getClassLoader().getResourceAsStream("jdbc.properties"); //读取properties文件并解析 prop.load(is); //获取连接数据库的url url = prop.getProperty("url"); //获取连接数据库的用户名 name = prop.getProperty("name"); //获取连接数据库的pwd pwd = prop.getProperty("pwd"); //获取数据库驱动全名 String drivername = prop.getProperty("driver"); //加载并注册驱动 Class.forName(drivername); } catch (Exception e) { e.printStackTrace(); } } //获取数据库连接对象 public static Connection getConnection(){ Connection connection = null; try{ connection = DriverManager.getConnection(url,name,pwd); }catch(SQLException e){ e.printStackTrace(); } return connection; } //关闭连接对象 public static void closeConnection(Connection connection){ try{ connection.close(); }catch(SQLException e){ e.printStackTrace(); } } //提交事务 public static void commit(Connection connection){ try{ connection.commit(); }catch(SQLException e){ e.printStackTrace(); } } //事务回滚 public static void rollback(Connection connection){ try{ connection.rollback(); }catch(SQLException e){ e.printStackTrace(); } } //关闭Statement对象 public static void closeStatement(Statement statement){ try{ statement.close(); }catch(SQLException e){ e.printStackTrace(); } } //关闭ResultSet public static void closeResulSet(ResultSet resultSet){ try{ resultSet.close(); }catch(SQLException e){ e.printStackTrace(); } } //DML操作时关闭资源 public static void closeResource(Statement statement,Connection connection){ //先关闭Statement对象 closeStatement(statement); //再关闭Connection对象 closeConnection(connection); } //查询时关闭资源 public static void closeResource(ResultSet resultSet,Statement statement,Connection connection){ //先关闭ResultSet closeResulSet(resultSet); //再关闭Statement对象 closeStatement(statement); //最后关闭Connection对象 closeConnection(connection); } } package com.itbaizhan; public class Test { public static void main(String[] args) { StatementTest statementTest = new StatementTest(); statementTest.insertUsers("Miao",19); } }
Statement_添加数据时报错,实在找不到原因
一:遇到的问题:
老师,这里的td标签里面id属性的值为什么既加单引号又加双引号
二:代码区:
str+= "<tr align='center'><td id='"+this.userid+"'>"+this.userid +"</td></tr>"
老师,现在的
pom文件中我也添加了该启动坐标,但是在启动类中没有@EableAdminServer这个注解。
admin服务端可以正常启动,但是在网页中输入localhost:9090出来不来界面,求解
#coding=utf-8 #测试os.walk()递归遍历所有的子目录和子文件 import os all_files = [] path = os.getcwd() list_files = os.walk(path) for dirpath,dirnames,filenames in list_files: for dir in dirnames: all_files.append(os.path.join(dirpath,dir)) for file in filenames: all_files.append(os.path.join(dirpath,file)) #打印所有的子目录和子文件 for file in all_files: print(file)
为什么会需要第一行的代码,不是注释掉了吗?还会起作用吗?
老师 这没有初始化怎么解决啊 我这个工具类之前是可以使用的啊 而且在service 层中 也获取了sqlsession
代码:
from urllib.request import Request,urlopen,HTTPCookieProcessor,build_opener from fake_useragent import UserAgent from http.cookiejar import MozillaCookieJar from urllib.parse import urlencode def get_cookie(): url = "https://conch.xiami.com/api/passports/login?_xm_cf_=X7XmPS6phj26eeGtm36-k9NS" form_data={ "user":13629949237, "password":"hgc950226" } headers={"User-Agent":UserAgent().random} rep=Request(url,headers=headers,data=(urlencode(form_data).encode())) cookiejar=MozillaCookieJar() handle=HTTPCookieProcessor(cookiejar) opener=build_opener(handle) resp=opener.open(rep) cookiejar.save("cookie.txt",ignore_discard=True,ignore_expires=True) get_cookie() add_url="https://conch.xiami.com/"
结果:
老师请问一下,我使用cookie登录虾米音乐的时候,为什么会出现这个问题?
老师,为什么我把index.html文件拉到META‐INF.resources下,static下的img目录就并入static一起了呢
感谢上一位同学的提示
消息队列怎么使用?老师可以具体说说嘛
视频里面说,hashset容器的元素是放在数组中的,那么按视频老师举的例子,假如a和b用哈希算法最终得出来存放位置的索引值都是2,在a已经先放入2的位置后,那b最终是放在数组中哪个索引位置了呢?
为什么调用不了getUsersage()方法?
org.springframework.boot spring-boot-starter-validation
需要加这个依赖,如果增加 NutNull失败的同学,可以试试加这个依赖就好了
这些数据表的源码在哪里嘞,都是一些表字段的说明 没有脚本呀,在哪里呀
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637