Working with JNDI??
Applications such as GeoServer are in position to work with database connection pools set up by the application server. The Java Naming and Directory Interface (JNDI) can be used to create a connection pool for a JDBC data source.
These instructions will set up a JNDI connection pool on the Tomcat application server using a PostgreSQL data source:
Tomcat is the application server used in:
- OpenGeo Suite for Ubuntu Linux
- OpenGeo Suite for Red Hat-based Linux
Tomcat can also be used with:
- OpenGeo Suite for Application Servers
Copy the JDBC Driver for your database to
<TOMCAT_HOME>/lib. The JDBC driver can often be found on the website of your DBMS provider, or in the installed version of your database.
The PostgreSQL JDBC Driver can be found at the PostgreSQL web site or in the
Remove the JDBC Driver from the
WEB-INF/libdirectory inside the GeoServer webapps directory. It should be named
Register the connection pool with the Tomcat Java Naming and Directory Interface (JNDI). This is done by adding a
<Resource\>entry to the
TOMCAT_HOME/conf/context.xmlconfiguration file. For example, given a PostgreSQL database named
testwith a user name and password of
admin, the configuration would look like this:
<Context> ... <Resource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/test" username="admin" password="admin" maxActive="20" maxIdle="10" maxWait="-1"/> </Context>
For more information about the possible parameters and their values refer to the DBCP documentation.
When adding a store in GeoServer, select the JNDI option. Enter the following information:
- The jndiReferenceName used by the application server.
- The schema used by the database.
Using the configuration example above, the jndiReferenceName would be
For more information, including how to configure JNDI for Oracle and SQL Server data sources, see the GeoServer user manual.