//北京时间东八区 serverTimezone=GMT%2B8
//北京时间东八区 serverTimezone=GMT%2B8 //或者使用上海时间 serverTimezone=Asia/Shanghai
useSSL=false
完整代码:
Class.forName("com.mysql.cj.jdbc.Driver"); String url="jdbc:mysql://localhost:3306/mydb3?serverTimezone=GMT%2B8&useSSL=false"; String user="root"; String password="123"; Connection connection = DriverManager.getConnection(url, user, password); System.out.println(connection);
Class.forName("com.mysql.cj.jdbc.Driver");
3、定义url,user,password
String url="jdbc:mysql://localhost:3306/mydb3?serverTimezone=GMT%2B8&useSSL=false"; String user="root"; String password="123";
4、通过DriverManager.getConnection得到connection
Connection connection = DriverManager.getConnection(url, user, password);
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/177055.html原文链接:https://javaforall.net
