java导入mysql jar包,注册驱动时发生错误:
Exception in thread “main” java.sql.SQLException: The server time zone value ‘�й���ʱ��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to
Exception in thread "main" java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
一运行就发生该错误。
后来发现这个是系统时间错误。
只需要在访问数据库的Url后面加上以下的语句即可:
?serverTimezone=GMT%2B8
例如URL为:
jdbc:mysql://localhost:port/my_test
修改为:
jdbc:mysql://localhost:port/my_test?serverTimezone=GMT%2B8
问题就迎刃而解啦。
新的开始
这是我的第一个博客,我也是一个编程小白,还在漫长学习之中…
以后会将编程中遇到的困难发到博客上,记录下来。
希望大家一起学习交流吧!