Skip to main content
Pentaho Documentation

Set Up JNDI Connections for the Pentaho Server

Instructions for adding JNDI connections vary depending on which web application server you are using.

  • If you installed the Pentaho Server using the Pentaho Installation Wizard, you are using a Tomcat web application server.
  • If you installed the Pentaho Server using the manual installation method, you are using either a Tomcat or JBoss web application server.

If you installed the Pentaho Server using the manual installation method, then you specified data connections to your Tomcat or JBoss web application server. If you want to modify existing connections or define more JNDI connections, perform the appropriate set of instructions below.

Audience: Only IT administrators who know where data is stored, how to connect to it, details about the computing environment, and how to use the command line to issue commands for Microsoft Windows or Linux. You should also know how to install a database and a web application server.

Defining JNDI Connections for PDI Clients

If you are publishing to the Pentaho Server from a PDI client, Pentaho supplies a method for you to configure your PDI client to have the same JNDI connection information as the Pentaho Server. By using this method, your application server will not be continuously running during the development and testing of transformations.

  • To configure a JNDI connection for your PDI client, edit the jdbc.prpoerties file to mirror the JNDI connection information of your application server data sources. The jdbc.properties file is located here: /pentaho/design-tools/data-integration/simple-jndi.

Add Drivers

The Pentaho Server needs the appropriate driver to connect to the database that stores your data. Your database administrator, Chief Intelligence Officer, or IT manager should be able to provide the appropriate driver. If not, you can download drivers from your database vendor's website. The Supported Technologies section contains a list of drivers.

Once you have the correct driver, copy it to the following directories:

  • Pentaho Server: /pentaho/server/pentaho-server/tomcat/lib/
  • Spoon: data-integration/lib 

You must restart Spoon for the driver to take effect.

There should be only one driver for your database in the directory. Ensure that there are no other versions of the same vendor's driver in this directory. If there are, back up the old driver files and remove them to avoid version conflicts. This is a concern when you are adding a driver for the same database type as your Pentaho Repository. If you have any concerns about how to proceed, contact Pentaho Support.

Driver for Microsoft SQL Server

If you are using a Microsoft SQL Server (MSSQL), you might need to use an alternative, non-vendor-supported driver called JTDS. Contact Pentaho Support to ensure that you are adding the correct driver.

For Microsoft Windows, most JDBC drivers support Type 2 integrated authentication through the integratedSecurity connection string property. To use integrated authentication, copy the sqljdbc_auth.dll file to all machines and directories to which you copied the JDBC driver. You can find this file in this location.

<installation directory>\sqljdbc_<version>\<language>\auth\
If running: Use the sqljdbc_auth.dll file here:
64-bit JVM on a x64 processor x64 folder
64-bit JVM on an Itanium processor IA64 folder

Tomcat JNDI Connections

If you installed the Pentaho Server using the manual installation method, then you specified data connections to your Tomcat web application server. If you want to modify existing connections or add more connections, perform the following tasks.

Database connection and network information, such as the username, password, driver class information, IP address or domain name, and port numbers for your Pentaho Repository database are stored in the context.xml file. Modify this file to reflect the database connection and network information to reflect your operating environment. You also modify the values for the validationQuery parameters in this file if you have choosen to use an Pentaho Repository database other than PostgreSQL.

  1. Stop the Tomcat and Pentaho servers.
  2. Consult your database documentation to determine the class name and connection string for your database.
  3. Edit the /tomcat/webapps/pentaho/WEB-INF/web.xml file.
  4. At the end of the <web-app> element, in the same part of the file where you see <!-- insert additional resource-refs -->, add the following XML snippet:
<resource-ref>
    <description>myDataSource</description>
    <res-ref-name>jdbc/myDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

Change the description and res-ref-name nodes, as well as any others that apply to your situation and fit your database. You may need to consult the JNDI Resources article in the Apache Tomcat documentation to see if there are other components to consider.

  1. Save and close the web.xml file.
  2. Edit the /tomcat/conf/context.xml with a text editor. Alternatively, you can modify the /tomcat/webapps/pentaho/META-INF/context.xml file if you want this data connection to be available only to the Pentaho Server. Adding JNDI connections to the context.xml makes them available to all of the webapps deployed to this Tomcat instance.
  3. Anywhere inside of the Context element, add the following XML snippet: 
<Resource name="jdbc/myDataSource" 
    auth="Container" type="javax.sql.DataSource"
    factory="org.apache.commons.dbcp.BasicDataSourceFactory" 
    maxTotal="20" 
    maxIdle="5"
    maxWaitMillis="10000" 
    username="dbuser" 
    password="password" 
    driverClassName="org.postgresql.Driver"
    url="jdbc:postgresql://127.0.0.1:5432/myDataSource"
/>   
  1. The example above shows a simple PostgreSQL configuration. Replace the Resource name, username, password, driverClassName, and url parameters, or any relevant connection settings, to match your database connection information and the details you supplied in the web.xml file earlier.
  2. Save and close the context.xml file.
  3. Delete the pentaho.xml filed located in the /tomcat/conf/catalina/directory. The pentaho.xml is a cached copy of the context.xml file you modified. Since the cache is not usually configured to update frequently, you have to delete the pentaho.xml file and let Tomcat recreate it when it starts up.
  4. Start the Tomcat and Pentaho servers.

Tomcat can now properly connect to your data.

Install JDBC Driver as a Module in JBoss

If you installed the Pentaho Server using the manual installation method, then you specified data connections to your JBoss web application server. If you want to modify existing connections or add more connections, perform the following tasks.

  1. Create the Module File for the Pentaho Repository Database
  2. Create the Module File for the HSQL Database
  3. Create the Module for the H2 Database
  4. Define JNDI Database Connection Information in JBoss
  5. Remove JNDI Resource References in JBoss
  6. Update JNDI Data Source Reference to Conform to JBoss Standards

In JBoss, JDBC driver information is stored in a module, which is an XML file that you create. You must download the JDBC driver software component to the correct directory, then create module.xml files for each database.

The JDBC Drivers Reference has a list of supported drivers.

Create Module File for Pentaho Repository Database

You need to create a file for the database that hosts the Pentaho Repository (either PostgreSQL, MySQL, or Oracle), as well as for HSQLDB.

  1. Locate the pentaho/server/pentaho-server/<your jboss installation directory>/modules/system/layers/base/org folder and create one of the following paths for the database on which you are hosting the Pentaho Repository.
    •  PostgreSQL: postgresql/main
    • MySQL: mysql/main
    • Oracle: oracle/main
    • MS SQL Server: sqlserver/main
  2. Create these two paths in the same directory.
    • HSQLDB: hsqldb/main
    • H2: h2/main
  3. Download the supported JDBC driver for your Pentaho Repository database to the directory that you just created. The JDBC Drivers Reference has a list of supported drivers.
  4. Within that directory, do the following things:
    1. Use an editor to create a text file named module.xml.
    2. Copy the appropriate code into the module.xml file, then modify it so that the name of the JDBC driver you just downloaded appears.
    3. Save and close the module.xml file.
Repository Type Module code

PostgreSQL

1 <?xml version="1.0" encoding="UTF-8"?>
2     <module xmlns="urn:jboss:module:1.0"name="org.postgresql">
3         <resources>
4             <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
5         </resources>
6         <dependencies><module name="javax.api"/></dependencies>
7     </module>
MySQL
1 <?xml version="1.0" encoding="UTF-8"?>
2     <module xmlns="urn:jboss:module:1.0"name="org.mysql">
3         <resources>
4             <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
5         </resources>
6         <dependencies><module name="javax.api"/></dependencies>
7     </module>
Oracle
1 <?xml version="1.0" encoding="UTF-8"?>
2     <module xmlns="urn:jboss:module:1.0"name="org.oracle">
3         <resources>
4             <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
5         </resources>
6         <dependencies><module name="javax.api"/></dependencies>
7     </module>
MS SQL Server
01 <?xml version="1.0" encoding="UTF-8"?>
02 <module xmlns="urn:jboss:module:1.0"
03 name="org.sqlserver">
04 <resources>
05 <resource-root path="[Name of JDBC
06 Jar You Downloaded Here]"/>
07 </resources>
08 <dependencies><module name="javax.
09 api"/></dependencies>
10 </module>

Create Module File for HSQL Database

You will need to create a module file for the HSQL database.

Caution: The version of HSQLDB used should be 2.3.2.

  1. Download the supported JDBC driver for HSQLDB and place it in the hsqldb/main directory.
  2. In the hsqldb/main directory, create a text file named module.xml.
  3. Copy this code into the module.xml file, then modify it so that the name of the JDBC driver you just downloaded appears in the resource-root path.
    1 <?xml version="1.0" encoding="UTF-8"?>
    2 <module xmlns="urn:jboss:module:1.0" name="org.hsqldb">
    3 <resources>
    4 <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
    5 </resources>
    6 <dependencies><module name="javax.api"/></dependencies>
    7 </module>
  4. Save and close the module.xml file.

Create Module File for H2 Database

You need to create a module file for the H2 database.

  1. In the h2/main directory, create a text file named module.xml.
  2. Copy this code into the module.xml file, then modify it so that the name of the JDBC driver you just downloaded appears in the resource-root path.
    1 <?xml version="1.0" encoding="UTF-8"?>
    2 <module xmlns="urn:jboss:module:1.0" name="org.h2">
    3 <resources>
    4 <resource-root path="[Name of JDBC Jar You Downloaded Here]"/>
    5 </resources>
    6 <dependencies><module name="javax.api"/></dependencies>
    7 </module>
  3. Save and close the module.xml file.

Define JNDI Database Connection Information in JBoss

JNDI is used to specify port, driver, user name, and password information for the Audit and Quartz databases that are housed on your Pentaho Repository database. This section shows you how to define your JNDI database connection information.

If you have a different database than PostgreSQL, or if you are using a different port, password, user, driver class information, or IP address, make sure that you adjust the examples in this section to match the ones in your environment.

  1. Copy the pentaho-style.war and pentaho.war files into the pentaho/server/pentaho-server/<your jboss installation directory>/standalone/deployment directory, or verify that the files are already there, as in PostgreSQL.
  2. Locate the pentaho/server/pentaho-server/<your jboss installation directory>/standalone/configuration/standalone.xml file and open it with a text editor.
  3. Insert these lines after the definition for ExampleDS data source.
    001 <datasource jndi-name="java:jboss/datasources/Hibernate" pool-name="hibpool"enabled="true" jta="true" use-java-context="true" use-ccm="true">
    002                         <connection-url>
    003                             jdbc:postgresql://localhost:5432/hibernate
    004                         </connection-url>
    005                         <driver-class>
    006                             org.postgresql.Driver
    007                         </driver-class>
    008                         <driver>
    009                             org.postgresql
    010                         </driver>
    011                         <pool>
    012                             <prefill>
    013                                 false
    014                             </prefill>
    015                             <use-strict-min>
    016                                 false
    017                             </use-strict-min>
    018                             <flush-strategy>
    019                                 FailingConnectionOnly
    020                             </flush-strategy>
    021                         </pool>
    022                         <security>
    023                             <user-name>
    024                                 hibuser
    025                             </user-name>
    026                             <password>
    027                                 password
    028                             </password>
    029                         </security>
    030                     </datasource>
    031                     <datasource jndi-name="java:jboss/datasources/Quartz" pool-name="quartzpool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
    032                         <connection-url>
    033                             jdbc:postgresql://localhost:5432/quartz
    034                         </connection-url>
    035                         <driver-class>
    036                             org.postgresql.Driver
    037                         </driver-class>
    038                         <driver>
    039                             org.postgresql
    040                         </driver>
    041                         <pool>
    042                             <prefill>
    043                                 false
    044                             </prefill>
    045                             <use-strict-min>
    046                                 false
    047                             </use-strict-min>
    048                             <flush-strategy>
    049                                 FailingConnectionOnly
    050                             </flush-strategy>
    051                         </pool>
    052                         <security>
    053                             <user-name>
    054                                 pentaho_user
    055                             </user-name>
    056                             <password>
    057                                 password
    058                             </password>
    059                         </security>