Creating a Data Source for Tomcat

Follow the instructions below to create a data source for Tomcat:

  1. Install the JDBC driver by installing the driver's JAR file(s) in the $CATALINA_HOME/common/lib directory.
  2. Add a connection. Modify the Web application deployment descriptor, pentaho/WEB-INF/web.xml, to declare the JNDI name under which you will look up the pre-configured data source. A typical web.xml entry is shown below:
    <resource-ref>
    <description>SampleData Connection</description>
    <res-ref-name>jdbc/SampleData</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    
  3. Under <Context path="/pentaho" docbase="webapps/pentaho/">, add an element like the one shown below to the pentaho-tomcat/tomcat/conf/server.xml file:
     
    <Resource name="jdbc/SampleData" auth="Container" type="javax.sql.DataSource" maxActive="20" maxIdle="5" maxWait="10000" username="pentaho_user" password="password" factory="org.apache.commons.dbcp.BasicDataSourceFactory" driverClassName="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:hsql://localhost/sampledata" />
     
    Notice that the resource name, jdbc/SampleData, must match the value specified in the Pentaho Web application deployment descriptor (web.xml). This example is for a HypersonicSQL database JDBC driver.
     
  4. Customize the driverClassName and driverName parameters to match your database's JDBC driver and connection URL.
     

Tomcat Configuration Properties

The configuration properties for Tomcat's standard data source resource factory (org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory) are listed below:

Configuration

Description

driverClassName

Fully qualified Java class name of the JDBC driver to be used.

maxActive

The maximum number of active instances that can be allocated from this pool at the same time.

maxIdle

The maximum number of connections that can sit idle in this pool at the same time.

maxWait

The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception.

password

Database password to be passed to our JDBC driver.

url

Connection URL to be passed to our JDBC driver. (For backwards compatibility, the property driverName is also recognized.)

user

Database user name to be passed to our JDBC driver.

validationQuery

SQL query that can be used by the pool to validate connections before they are returned to the application. If specified, this query must be an SQL SELECT statement that returns at least one row.

See also:[http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html]