问题相关代码,请勿粘贴截图
public class JDBCDemo {
public static void main(String[] args) throws Exception {
// 注册驱动
Class.forName("com.mysql.jdbc.Driver");
// 获取链接
String url="jdbc:mysql://localhost:3306/qimeng?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false";
String username="root";
String password="123456";
Connection conn=DriverManager.getConnection(url,username,password);
// 定义sql
String sql="insert into qimeng_user (username,password) values('root','123456')";
// 获取执行sql的对象:Statement
Statement stmt=conn.createStatement();
// 执行sql
int count= (int) stmt.executeLargeUpdate(sql); //count:受影响行数的返回值
// 处理结果
System.out.println(count);
// 释放资源
stmt.close();
conn.close();
}
}
运行结果及报错内容
Exception in thread "main" java.sql.SQLException: Unknown system variable 'performance_schema'