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");

 

转载于:https://www.cnblogs.com/jadeshu/p/10663581.html

评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符 “速评一下”
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页