How can I create database connections for all servlets?
The standard way to preserve database connections between servlet requests is to use a connection pool that governs access to a number of live connections. The pool uses your primary database driver to create the connections in advance and makes pooled connections available through its own URL identifier. When the application closes a pooled connection it just returns to the pool. A database connection pool can be created and managed directly by your servlet application, or obtained through the servlet container using the Java Naming and Directory Interface (JNDI). The Apache Commons DBCP project provides the database connection pooling service used by the Tomcat servlet container, but can also used independently from the container. Container managed connection pools must be accessed using the javax.sql.DataSource interface, as outlined in the Tomcat JNDI Datasource HOW-TO. Actions: Follow-up or correct this answer. Submit a new question.