您的位置:首页 > 编程语言 > Java开发

更换mysql-connector-java-6.0.5jar包后程序出现的两个异常及解决方法

2017-07-02 00:31 681 查看
异常一:Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered
via the SPI and manual loading of the driver class is generally unnecessary.
异常二: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.

 解决方法:
第一个异常是因为mysql-connection-java的最新版本不建议使用“com.mysql.jdbc” 包下面的“Driver”,改正方法直接把配置文件中的“com.mysql.jdbc.Driver”改为在异常中提示的“com.mysql.cj.jdbc.Driver”。

 
第二个异常显示新版本的数据库连接程序需要指定UTC时区,改正方法将配置文件中的“url”后面加上指定的时区,将其值改为“url=jdbc:mysql://localhost:3306/。。。&serverTimezone=GMT”
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐