Hibernate + mysqltoomanyconnections Error

Source: Internet
Author: User
Hibernate + mysqltoomanyconnections exception analysis: when using Hibernate to connect to MySQL, the following exception occurs after multiple query operations (the number of queries executed equals the value of MySQL's max-connection parameter): Datasourcerejectedestablishmentofconnection, messagefromserver: Tooma

Exception Analysis of hibernate + mysql too connector connections: connect to MySQL using Hibernate. The following exception occurs after multiple query operations (the number of queries executed equals the value of the max-connection parameter of MySQL): Data source rejected establishment of connection, message from server: "Too ma

Exception in hibernate + mysql too connector connections

Problem Analysis:

Connect to MySQL using Hibernate. The following exception occurs after multiple query operations (the number of queries executed is equal to the value of the max-connection parameter of MySQL ):

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

? Solution:

After the query operation is completed, only session. close (); is called to close the session.

Call factory. close (); To disable SessionFanctory.

If both of them are disabled, the above exceptions will not occur.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.