gpt4 book ai didi

java - 如何使用eclipse连接java与MySQL数据库

转载 作者:行者123 更新时间:2023-11-29 10:04:02 24 4
gpt4 key购买 nike

我收到错误

Error:java.sql.SQLException: The server time zone value 'Malay Peninsula Standard Time' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the server timezone configuration property) to use a more specific time zone value if you want to utilize time zone support. java.lang.NullPointerException

我尝试使用本地时区更改计算机的时间,但仍然出现相同的错误。

我尝试添加我的连接:

"jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliatnTimezoneShift=true&useLegacyDatetimeCode=false","root",""

仍然没有工作,我收到错误:

Error:java.sql.SQLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the connection string near ';useJDBCCompliatnTimezoneShift=true&useLegacyDatetimeCode=false'. java.lang.NullPointerException

我的连接字符串是:

Class.forName("com.mysql.cj.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/raqs","root","");

最佳答案

修正你的错字。是“合规”,不是“合规”。正如错误所示。

关于java - 如何使用eclipse连接java与MySQL数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52306048/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com