Previous Topic: Enabling Database Connection PoolingNext Topic: IBM WebSphere


Apache Tomcat

This section provides the steps to enable Apache Tomcat for JNDI-based database operations.

Perform the following steps to create a JNDI connection in Apache Tomcat:

  1. Install the Apache Tomcat application server and test the installation using the following URL:

    http://localhost:8080/

    The preceding URL must open the Apache Tomcat home page.

  2. Open the server.xml file present in the <TOMCAT-HOME>/conf directory.
  3. Collect the following information required to define a data source:
  4. Add the following entry to define the datasource within the <GlobalNamingResources> tag:
    <Resource name="SampleDS"
    auth="Container"
    type="javax.sql.DataSource"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    username="<userid>"
    password="<password>"
    driverClassName="<JDBC driver class>"
    url="<jdbc-url>"
    maxWait="30000"
    maxActive="32"
    maxIdle="8"
    initialSize="4"
    timeBetweenEvictionRunsMillis="300000"
    minEvictableIdleTimeMillis="30000"/>
    
  5. Open the context.xml file present in the <TOMCAT-HOME>/conf directory.
  6. Add the following entry to define the datasource within the <Context> tag:
    <ResourceLink global="SampleDS" name="SampleDS" type="javax.sql.DataSource"/>
    
  7. Copy the following database connection pooling (DBCP) dependencies to <TOMCAT-HOME>/common/lib directory.