本文主要是介绍jdbc连接mysql报错The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one t,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
mysql8.0在连接jdbc后报错
源代码:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;import com.mysql.jdbc.Driver;public class ConnectMysql {public static void main(String[] args) throws ClassNotFoundException, SQLException {Class.forName("com.mysql.cj.jdbc.Driver");String url="jdbc:mysql://localhost:3306/ljj?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL";String user="root";String password="123";Connection conn=DriverManager.getConnection(url,user,password);System.out.println(conn);}
}
把url改一下
String url="jdbc:mysql://localhost:3306/ljj?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL";
修改url后连接成功
这篇关于jdbc连接mysql报错The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one t的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!