MySql :Could not create connection to database server.
Posted 唐火
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySql :Could not create connection to database server.相关的知识,希望对你有一定的参考价值。
错误:
Exception in thread “main” org.apache.ibatis.exceptions.PersistenceException:Error querying database. Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
The error may exist in cn/action/dao/UserDao.xml
The error may involve cn.action.dao.UserDao.findList
The error occurred while executing a query
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:136)
at cn.action.test01.TestSelectList.main(TestSelectList.java:29)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
原因:
MySql8.0应用低版本jar包,产生错误
解决:
1.下载高版本jar包
下载后解压:
2.更改驱动名
以前:com.mysql.jdbc.Driver
更改后:com.mysql.cj.jdbc.Driver
3.删除原来的驱动包
项目上右键->Build Path->Configure Build Path->Libraries中带错误的jar包remove
4.由于版本时区不同,要在数据库后加上“?serverTimezone=UTC"
以上是关于MySql :Could not create connection to database server.的主要内容,如果未能解决你的问题,请参考以下文章
Jmeter连接Mysql出现Cannot create PoolableConnectionFactory (Could not create connection to database serv
jmeter连接mysql数据库报错Cannot create PoolableConnectionFactory (Could not create connection to database s
Idea连接MySQL异常[Could not create connection to database server. Attempted reconnect 3 times.]
Idea连接MySQL异常[Could not create connection to database server. Attempted reconnect 3 times.]
Idea连接MySQL异常[Could not create connection to database server. Attempted reconnect 3 times.]
java项目连接jdbc报错:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not creat