hibernate+mysql too many connections异常 问题分析: 使用hibernate连接mysql,多次执行查询操作后会出现以下异常(执行查询的次数等于mysql的max-connection参数的值): data source rejected establishment of connection, message from server: too ma
hibernate+mysql too many connections异常
问题分析:
使用hibernate连接mysql,多次执行查询操作后会出现以下异常(执行查询的次数等于mysql的max-connection参数的值):
data source rejected establishment of connection, message from server: too many connectionsorg.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
?解决方法:
在执行完查询操作后,仅仅调用了session.close();来关闭session,而没有
调用factory.close();来关闭sessionfanctory。
二者都关闭后不再出现上述异常。