Search code examples
javamysqltomcatservletsconnection-pooling

Will Tomcat maintain a MySql connection pool automatically ?


I'm new to java servlet programming.

In my doPost method, I will do fetch data from mysql database and write something back. I know I should somehow use a connection pool to improve performance. But wondering how. Should I main a connection pool in my java code or just need to config tomcat server?

Can you give me some suggestions about how to do this?


Solution

  • Yes. See the tomcat documentation here which describes how to configure MySQL DBCP (Database Connection Pool). Also you might consider setting up 'Preventing database connection pool leaks' configurations to reuse abandoned connections.