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
    
  • 相关阅读:
    待整理[图片验证码的破解]
    关于反爬的思索[集合]
    关于showdoc的服务器部署[转]
    jQuery插件实现多图片和单图片上传
    FTP 图片上传
    多线程(临界点处理)
    Python可迭代对象、迭代器和生成器
    一文搞懂Python函数(匿名函数、嵌套函数、闭包、装饰器)!
    Python比较操作符、变量赋值、对象拷贝
    Python并发编程——多线程与协程
  • 原文地址:https://www.cnblogs.com/wenqiangit/p/11006156.html
Copyright © 2011-2022 走看看