Java中连接mysql数据库常见的几种错误

1.1 异常
Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
不建议在没有服务器身份验证的情况下建立SSL连接。根据MySQL 5.5.45+, 5.6.26+和5.7.6+的要求,如果没有设置显式选项,则必须默认建立SSL连接

解决:
需要在 jdbc url 后加上&useSSL=false

1.2 异常
com.zaxxer.hikari.pool.HikariPool: HikariPool-1 - Exception during pool initialization.
引起程序无法启动的问题是 com.zaxxer.hikari.pool.HikariPool 没能成功被 Spring 创建,原因是你的时区配置的有歧义,

解决:
在 jdbc url 后加上 &serverTimezone=Asia/Shanghai 

1.3 警告
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

加载类“com.mysql.jdbc.Driver”。这是弃用。新的驱动程序类是“com.mysql.cj.jdbc.Driver”。驱动程序是通过SPI自动注册的,通常不需要手动加载驱动程序类。

你可能感兴趣的:(笔记)