Could not open JDBC Connection for transaction; nested exception is java.sql.SQLNonTransientConnecti

在练习事务的相关代码时候一直报这个错误,也就是连接数据库连接异常,可以尝试从以下几个方面排查和解决:

1.安全协议 问题:useSSL设置为false

&useSSL=false

配置数据连接的字段上加一个useSSL=false;
图片[1] - Could not open JDBC Connection for transaction; nested exception is java.sql.SQLNonTransientConnecti - MaxSSL

2.时区问题:在连接字符串加serverTimezone=UTC

图片[2] - Could not open JDBC Connection for transaction; nested exception is java.sql.SQLNonTransientConnecti - MaxSSL
再不行试试

jdbc:mysql://ip:3306/database" />3.请求量太高导致数据库连接数不够:修改最大连接数 

使用MyBatis的SqlSession是不会自动关闭数据源连接的,需要使用Spring包装过的SelSqlSessionTemplate才会自动关闭数据源连接。所以每次执行一个请求对应的方法,都会占用一个数据源连接而不被释放,最终导致数据源连接池被占满,无法开启新的连接。

配置参数:

 datasource: hikari: maximum-pool-size: 600

hikari连接池其他配置:
图片[3] - Could not open JDBC Connection for transaction; nested exception is java.sql.SQLNonTransientConnecti - MaxSSL
图片[4] - Could not open JDBC Connection for transaction; nested exception is java.sql.SQLNonTransientConnecti - MaxSSL

4.mysql设置的账号访问权限不对

查看方法:
图片[5] - Could not open JDBC Connection for transaction; nested exception is java.sql.SQLNonTransientConnecti - MaxSSL

5.mysql驱动版本和mysql版本不一致
6.Could not create connection to database server. Attempted reconnect 3 times.
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享