%@page import="javax.naming.*" %>
simplepool
|
Summary | A simple database connection pool example using JDNI. |
---|---|
Example 1 | Scriptlet Example [source] |
Example 2 | JSTL Example [source] |
JNDI is used to create, access and manage the connection pool.
First, make sure that your JDBC driver is available, by placing its components in this webapp's WEB-INF/lib/ directory.
The JNDI DataSource is defined as naming resource in the current webapp context, as shown in this minimal server configuration file.
The JNDI DataSource is configured using the following parameters:
example: com.mysql.jdbc.Driver
.jdbc:mysql://localhost:3306/dbname
.Please note that all parameters are required.
Please take a minute to incorporate the JDNI DataSource example in your $CATALINE_HOME/conf/server.xml
. Once done, please restart Tomcat. The examples will be functional upon restart.
Please look at the [source] of the provided examples to understand how to access the connection pool from a scriptlet or using the JSTL SQL tags. The examples demonstrates how to list all of the tables contained in the specified database.