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
    
  • 相关阅读:
    Self Numbers
    【acdream】小晴天老师系列——竖式乘法
    全错位排列
    2 ^ x mod n = 1问题
    基于cocos2dx的横版动作游戏制作(二)
    基于cocos2dx的横版动作游戏制作(一)
    横版游戏制作之英雄技能CD遮罩,人物头像血条属性
    cocos2d横版游戏之摇杆控制
    C++ delete []p 数组指针,如何知道该数组大小的
    do { ....} while(0) 在宏里冗余的意义
  • 原文地址:https://www.cnblogs.com/wenqiangit/p/11006156.html
Copyright © 2011-2022 走看看