8

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!

2
  • Whatever you do, make sure that you don't use Apache's DBCP. It's a horrible implementation that will actually cause performance problems, not fix them. Commented Dec 1, 2008 at 4:43
  • 2
    ...so what do you use instead? Commented Aug 12, 2009 at 13:00

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

This isn't correct at all. You should use the built in pooling in Tomcat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.