关于使用mysql 8版本以上的朋友 肯定会遇到这些问题 !
连接时区问题
自动创建表问题
什么主键问题
等等等等
这遍文章都可以给你解决掉
8版本的驱动,弃用了原来的方法,我们直接去看源码也能找到。
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.
改用新的驱动程序类是`com.mysql.cj.jdbc.Driver’
还有一个url的问题
characterEncoding=utf8 (字符编码)
useSSL=false (发现是8版本开始才需要添加,5.X印象中不需要,添加这个参数可能和MySQL的SSL连接设置有关系)
serverTimezone=UTC (当连接数据库时候,出现Time Zone错误时添加此参数,我貌似是使用Druid连接池时才出现的这个问题)
allowPublicKeyRetrieval=true (使用root账户登陆没问题,使用普通账户会提示Public Key Retrieval错误)
nullCatalogMeansCurrent=true (自动创建更新数据库表)
用这个 包治百病
url: jdbc:mysql://localhost:3306/ajyl_medical_model?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true