欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

hibernate连接mysql密码错误,hibernate+mysql too many connections错误

发布时间:2025/3/20 数据库 43 豆豆
生活随笔 收集整理的这篇文章主要介绍了 hibernate连接mysql密码错误,hibernate+mysql too many connections错误 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

问题分析:

使用Hibernate连接MySQL,多次执行查询操作后会出现以下异常(执行查询的次数等于MySQL的max-connection参数的值):

Data source rejected establishment of connection, message from server: "Too many connections" org.hibernate.exception.JDBCConnectionException: Cannot open connection at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at org.hibernate.jdbc.ConnectionManager.openConnectionCaused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections" at com.mysql.jdbc.SQLError.createSQLException

欢迎大家阅读《hibernate+mysql too many connections错误》,跪求各位点评,by 搞代码

解决方法:

在执行完查询操作后,仅仅调用了session.close();来关闭session,而没有

调用factory.close();来关闭SessionFanctory。

二者都关闭后不再出现上述异常。

与50位技术专家面对面20年技术见证,附赠技术全景图

总结

以上是生活随笔为你收集整理的hibernate连接mysql密码错误,hibernate+mysql too many connections错误的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。