Follow the instructions below to create a data source for Tomcat:
- Install the JDBC driver by installing the driver's JAR file(s) in the $CATALINA_HOME/common/lib directory.
- 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>
- 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.
- 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:
Fully qualified Java class name of the JDBC driver to be used.
The maximum number of active instances that can be allocated from this pool at the same time.
The maximum number of connections that can sit idle in this pool at the same time.
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.
Database password to be passed to our JDBC driver.
Connection URL to be passed to our JDBC driver. (For backwards compatibility, the property driverName is also recognized.)
Database user name to be passed to our JDBC driver.
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.