How can I use Connection pool in Java+MySQL+Tomcat 6?
如何在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.
我已经阅读了这篇文章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为任意对象提供强大的池功能。
See detailed example in this post: How to set up a MySQL connection pool in Java
请参阅本文中的详细示例:如何在Java中设置MySQL连接池
#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为任意对象提供强大的池功能。
See detailed example in this post: How to set up a MySQL connection pool in Java
请参阅本文中的详细示例:如何在Java中设置MySQL连接池