600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > MySql :Could not create connection to database server.

MySql :Could not create connection to database server.

时间:2020-04-07 04:31:09

相关推荐

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"

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。