那些搞不懂的数据库连接异常

Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30010ms.

原因:请求数据库连接时长时间未获取到时,会报这个错误
修改配置项:datasource.primary.connection-timeout=30000

Cause: com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client request

原因:脚本执行时间太长,客户端自动断开
修改配置项:mybatis.configuration.default-statement-timeout=30

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.

原因:数据库端关闭了连接
修改数据项:数据库配置wait_timeout

org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.

原因:服务正在重启,导致部分连接失效

相关:https://blog.csdn.net/superdangbo/article/details/78744774

你可能感兴趣的:(mysql)