How to use connection pool with java,MySQL and Tomcat 6

断了今生、忘了曾经 提交于 2020-01-03 08:33:09

问题


How can I use Connection pool in Java+MySQL+Tomcat 6?

I've read this article http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html but it is still not quite clear for me.

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?

Thank you in advance!


回答1:


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.




回答2:


You can easily implement MySQL connection pooling in Java by using Java's GenericObjectPool that provides robust pooling functionality for arbitrary objects.

See detailed example in this post: How to set up a MySQL connection pool in Java



来源:https://stackoverflow.com/questions/329666/how-to-use-connection-pool-with-java-mysql-and-tomcat-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!