在做springMVC+Mybatis项目时,出现了Could not create connection to database server的错误,现已解决,提供思路如下:
- 检查MySQL版本和JDBC(mysql-connector-java-…)是否一致。打开MySQL Command Line Client 输入SELECT version() FROM dual看MySQL的版本号,若不一致去下载该版本号的JDBC(示例图如????)
若仍提示该错误,则看第二步????
- 在配置文件mybatis-config.xml找到你连接数据库的url的value,然后在mybatis后加?serverTimezone=UTC(如图????)
另外解决: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. 的办法–同样在mybatis-config.xml中,改为如????(加入’cj’)