2018-05-27 Mysql的两种异常以及解决办法

异常一: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.

这是我当时配置的数据库,一运行就显示上面错误。。。。。



driverClass="com.mysql.jdbc.Driver"  

connectionURL="jdbc:mysql://localhost:3306/ssm_crud"  

userId="root"  

password="142014068">  


解决方法:

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


   第二个异常显示新版本的数据库连接程序需要指定UTC时区,改正方法将配置文件中的“url”后面加上指定的时区,将其值改为


jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ssm_crud?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT   

jdbc.driverClass=com.mysql.cj.jdbc.Driver  

jdbc.user=root  

jdbc.password=142014068  

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容