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

标签 java mysql eclipse

我收到错误

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/

相关文章:

java - JFXButton 看起来在启动后立即被单击

java - 刷新列表查看项目android

c# - 使用 ASPNETDB.MDF 添加到 c# asp.net 中的表

PHP Mysql 选择

mysql - 使用内连接时 SQL 结果未达到预期

eclipse - 是否可以将jsp预编译到eclipse中?

java - Eclipse Java 控制台应用程序未显示

java - Spring CSRF 覆盖安全 XML 配置中的 "POST"注销行为

java - 如何在 Netty 客户端中漂亮地打印 http body?

java - 检测 2D 图形填充矩形是否在另一个填充矩形中(eclipse)