会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133633个问题
JAVA 全系列/第五阶段:网页编程和设计/Javascript 语言(旧) 19607楼
Python 全系列/第一阶段:Python入门/Python入门(动画版) 19608楼
JAVA 全系列/第八阶段:Linux入门到实战/Maven 19609楼
Python 全系列/第二十四阶段:人工智能基础_机器学习理论与实战/KNN与交叉检验 19610楼
JAVA 全系列/第一阶段:AI驱动的JAVA编程/控制语句、方法、递归算法 19611楼

3tank24.rar

上面提问报错的,谢谢老师帮忙看下

Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 19612楼
Python 全系列/第一阶段:Python入门/编程基本概念 19613楼
JAVA 全系列/第七阶段:项目管理与SSM框架/Mybatis 19614楼
Python 全系列/第二十四阶段:人工智能基础_机器学习理论与实战/KMeans聚类与降维算法 19615楼

老师 老师,http://effbot.org/tkinterbook/

这个网站,我怎么登不上,是要翻墙的吗

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 19616楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO流技术 19618楼

package java03192;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcTest {

	/**
	 * @param 张楠楠2019年5月30日14:35
问题:
1、使用jdk中的反射机制,啥是反射机制自己都忘了。
2、Fri May 31 09:16:56 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.1
3、快捷按键
	 */
	//向Department表中添加一条数据;
	public void insertDepartment( String department_name,int location_id){
		Connection conn=null;
		Statement state=null;
		//驱动注册-》数据库驱动实例化,使用jdk中的反射机制;
		try {
			//驱动注册
			Class.forName("com.mysql.jdbc.Driver");
			//获取连接
			conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bjsxt?useUnicode=true&characterEncoding=utf-8", "root", "root");//返回connction对象
			String sql="insert into departments values(default,'"+department_name+"',"+location_id+")";
			//创建能够发送数据的对象
			state=conn.createStatement();
			int flag=state.executeUpdate(sql);
			System.out.println(flag);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();//数据库中的驱动在数据库中的驱动包中=com.mysql.jdbc.Driver.class,driver.class,有一个非运行异常
		}finally{
			//释放资源
			if(state !=null){
				try {
					state.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn!=null){
				try {
					conn.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		
	}
//更新departments表中的department_id 为6的数据,将部门名称改为数学部,location_id修改为6
	public void updateDepartment(String department_name,int department_id,int location_id){
		Connection conn=null;
		Statement state=null;
		try{
			Class.forName("com.mysql.jdbc.Driver");
			conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bjsxt?useUnicode=true&characterEncoding=utf-8", "root", "root");
			String sql="UPDATE departments d SET d.department_name='"+department_name+"',d.location_id="+location_id+" WHERE department_id="+department_id+"";
			//String sql="insert into departments values("+department_id+",'"+department_name+"',"+location_id+")";
			int flag=state.executeUpdate(sql);
			System.out.println(flag);
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			//释放资源
			if(state !=null){
				try {
					state.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn!=null){
				try {
					conn.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
	public static void main(String[] args) {
		JdbcTest test=new JdbcTest();
		//test.insertDepartment("研发部3", 10);
		test.updateDepartment("数学部",3 , 10);

	}

}
Fri May 31 10:36:35 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
java.lang.NullPointerException
	at java03192.JdbcTest.updateDepartment(JdbcTest.java:65)
	at java03192.JdbcTest.main(JdbcTest.java:92)

老师提示报错,查了找不到原因,请帮忙看看。

JAVA 全系列/第四阶段:数据库与AI协同技术实战/JDBC技术(旧) 19619楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637