zoukankan      html  css  js  c++  java
  • MySQLNonTransientConnectionException: Could not create connection to database server.

    MySQLNonTransientConnectionException: Could not create connection to database server.

    Spring整合mybatis并使用driud数据库连接池,启动测试类就报”MySQLNonTransientConnectionException: Could not create connection to database server.“,检查了一番配置文件没发现问题,而且我之前用过这些配置,按理说没问题。各种百度、谷歌没结果,想起来装了mysql 8.0,估计是这个问题。既然是这个问题,那么问题出在数据库连接驱动,看了下pom文件,发现用的是5.1.4版本,于是找了个8.0.11版本重新启动,果然报错就不一样了。

    2018-05-26 16:52:53,928 [Druid-ConnectionPool-Create-1150963491] [com.alibaba.druid.pool.DruidDataSource]-[ERROR] create connection error
    java.sql.SQLException: validateConnection false
    

    另外在控制台上还打印了”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.“,意思是这个驱动类已经过时了,那只能说明MySQL 8.0使用的数据库连接字符串不一样。改完后重新启动搞定。

    需要说明的是mysql 8.0版本还对时区有要求,否则启动提示”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.“

    有个别人的示例可以参考下:https://blog.csdn.net/beyond9305/article/details/80330125

    贴一下连接字符串

    url: jdbc:mysql://localhost:3306/yinliu?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true
    driver: com.mysql.cj.jdbc.Driver
    
  • 相关阅读:
    【win10】浏览器Chrome 和edge 体验对比与使用心得
    【Java】 VM 环境配置过程要点( win10,64位)
    office2013 激活方法
    产品激活 比如Windows激活 , office激活 等激活的原理是什么? KMS等激活工具安全吗?
    回顾外滩踩踏事件,吸取的教训
    【win7】Ubuntu安装使用中的一些注意事项
    黑屏
    mock测试(一)
    Django模型类(一)
    获取本机局域网ip和出口ip
  • 原文地址:https://www.cnblogs.com/wenqiangit/p/11006156.html
Copyright © 2011-2022 走看看