Mysql版本java问题(com.mysql.cj.jdbc.Driver和com.mysql.jdbc.Driver)
老版本com.mysql.jdbc.Driver已弃用
String url1 = "jabc:mysql://127.0.0.1:3306/test";
String url1 = "jabc:mysql://localhost:3306/test";
新版用com.mysql.cj.jdbc.Driver
UTC:全球时间
Asia/Shanghai:上海时间
GMT%2B8:北京时间
String url = "jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false";
String url = "jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false";
String url = "jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false";
其中test:为数据库名
//Class.forName("com.mysql.jdbc.Driver");
//String url = "jabc:mysql://127.0.0.1:3306/test";
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/test?characterEncoding=UTF-
8&serverTimezone=UTC&useSSL=false";
Connection conn = DriverManager.getConnection(url, "root", "root");