异常一: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
网友评论