If you do a lot of database queries, opening and closing a new connection every time is very inefficient. Therefore, you want to use connection pooling. Basically, you will need to write a
Java class to represent the connection pool, possibly as a singleton. When this class is instantiated, it opens a specified number of database connections. Whenever your
JSP pages or servlets need to open a connection, they request it from the connection pool class instead of creating a new one. The pool class then checks if it still has an open connection and returns it, or it blocks and waits until a connection is available again.
-Mirko