Today's Question: 


Different programming are similar in helping people build staff work as people want them to. But they all have their own features which differentiate them from other programming languages. The language type may be different, for example Java is OOP, some may have different syntax. A programming motto usually can best describe the characteristic of the programming language. For example, "Write once Run everywhere" for Java.Do you know any other programming language motto?
Do you know the mottos of programmig languages?
Description My Answer

Technical Article => Database =>  MySQL

Solve Hibernate "Too many connections" issue in MySQL

Source : sonic0002    Date : 2013-09-04 22:20:49  

When working with Hibernate and MySQL, sometimes some exceptions will be thrown after sometime. The exception may seem like :

java.sql.SQLException: Data source rejected establishment of connection, message from server: "Too many connections"

This means there are too many active connections on the MySQL, you can use

SHOW STATUS LIKE '%Threads_connected%';

to check the active connections to MySQL. If you want to change the maximum connections allowed to MySQL. You can execute:

set global max_connections = [num];

You may forget to manually call session.close() methods iin your codes. If you have done this in all methods. Then you should not forget to call sessionFactory.close() when you have done all the requests. Most of the time, it's because you forget to call sessionFactory.close(). So please don't forget to call sessionFactory.close().

Also Hibernate's own connection pooling algorithm is, however, quite rudimentary. It is intended to help you get started and is not intended for use in a production system, or even for performance testing. You should use a third party pool for best performance and stability. Just replace the hibernate.connection.pool_size property with connection pool specific settings. This will turn off Hibernate's internal pool. For example, you might like to use c3p0.

Save as PDF Mark as read Mark as important
By clicking the "Mark as read" button, this article will be marked as read. It will be removed from the homepage's latest news and the article list on the "Technical article" page in following visits and it will be put to your read list which you can find in "Amin->Article read list". There you can unmark the read articles.
By clicking the "Mark as important" button, this article will be put to your important article list which you can find in "Amin->Article important list". Later when you want reread this article, it's easier for you to find it by checking the "Article important list".

Tags : MySQL,Hibernate,Clos   Read(2776) Comment(1) Version(0)

Share on Facebook  Share on Twitter  Share on Google+  Share on Weibo  Share on Reddit  Share on Digg  Share on Tumblr    Delicious 

 Previous : Do you have this kind of comments in your source code?
 Next : Female friendly programming languages

  ::Related Articles

  ::Comment Zone  (Total 1 comment)

集成显卡 [Reply]@ 2013-09-05 21:04:56



后来用了 c3p0 解决此问题



:: Other versions

No other versions available yet.

:: Recent articles

:: Most read

:: Contribute

Want to share with the world your understanding about technology? Want to record the process you solve a technical problem? Want to make the world benefit from your understanding and solution? Write them down. You make the world better, the world makes us better.

Write article

:: Find us

Back to top