How can I use Connection pool in Java+MySQL+Tomcat 6?
如何在Java + MySQL + Tomcat 6中使用連接池?
我已經閱讀了這篇文章http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html,但對我來說仍然不太清楚。
Where do I use the Connector/J? Do I put it in a static variable? Do I use a SessionListener? Does it need any configuration?
我在哪里使用Connector / J?我把它放在靜態變量中嗎?我使用SessionListener嗎?它需要任何配置嗎?
Thank you in advance!
先謝謝你!
2 个解决方案
#1
7
You should read the Tomcat 6 JNDI document. Look for the "JDBC Data Sources" section and it will tell you everything you need to know about pooling connections with Tomcat.
您應該閱讀Tomcat 6 JNDI文檔。查找“JDBC數據源”部分,它將告訴您有關池與Tomcat連接的所有信息。
#2
0
You can easily implement MySQL connection pooling in Java by using Java's GenericObjectPool that provides robust pooling functionality for arbitrary objects.
您可以使用Java的GenericObjectPool輕松地在Java中實現MySQL連接池,該GenericObjectPool為任意對象提供強大的池功能。
請參閱本文中的詳細示例:如何在Java中設置MySQL連接池