How to Set Up JNDI Data Sources

The Java Naming and Directory Interface (JNDI) configuration allows the JasperReports Server connectivity to appropriate databases using JDBC drivers. To run reports, the JNDI configuration is required.

IMPORTANT: In case of Jasper Server 8.0.x and MySQL db, delete the mariadb-java-client-x.x.x file from Tomcat lib folder, path : <jasper_installation_folder\apache-tomcat\lib.

To set up the Jasper data sources, follow these steps:

  1. From your Jasper install location, open the context.xml file.

    For example, \Jaspersoft\jasperreports-server-<8.0.0 or 7.1.0>\apache-tomcat\webapps\jasperserver-pro\META-INF\context.xml.

  2. In the context.xml file, add the following JNDI configurations for the reports to access the reports database. You must replace the following fields with appropriate values to access the reports database details. For more details, refer to Kony Fabric_Installer_Guide > Installing Kony Fabric > Database Details window.

    IMPORTANT: JasperReports Server V8.0, V7.1.0, and V6.2.0 use Tomcat 8 whereas JasperReports Server V 6.0 is bundled with Tomcat 7.

    And data source factory is different for both Tomcat 7 and Tomcat 8.

    - For JasperReports Server V8.0, V7.1.0 , and V6.2.0, the data source is as follows:
    factory="com.jaspersoft.jasperserver.tomcat.jndi.JSCommonsBasicDataSourceFactory

    - For JasperReports Server V6.0, the data source is as follows:
    factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory

    NOTE: In the Installing Kony Fabric page, scroll down to the Database Details window.

    Field NameValue
    <username>Database User
    <Database Server IP : Database PORT>Database Server Hostname/IP
    <password>Database Password
    <database_name> Reports Database Name
    • The following JNDI configuration is for the DB2 Server:
      <!-- For JasperReports Server 8.0/7.1 -->
      
      <!-- Add the following sample code for the Reports DB, to the existing context.xml -->
       
      <Resource name="jdbc/onpremdb2" auth="Container"
      	type="javax.sql.DataSource"
      	maxActive="100" maxIdle="30" maxWait="10000"
      	username="<username>" password="<password>"
      	driverClassName="com.ibm.db2.jcc.DB2Driver"
      	validationQuery="SELECT 1 from SYSIBM.SYSDUMMY1"
      	testOnBorrow="true"                   
      	 url="jdbc:db2://<Reports Database Server IP: Database
      	PORT>/<reports_database_name>:driverType=4; currentSchema=<Schema_name>;
      	factory="com.jaspersoft.jasperserver.tomcat.jndi.JSCommonsBasicDataSourceFactory"/>
      
      
      <!-- Add the following sample code for the Accounts DB, to the existing context.xml -->
      
      <Resource name="jdbc/onpremdb2" auth="Container"
      	type="javax.sql.DataSource"
      	maxActive="100" maxIdle="30" maxWait="10000"
      	username="<username>" password="<password>"
      	driverClassName="com.ibm.db2.jcc.DB2Driver"
      	validationQuery="SELECT 1 from SYSIBM.SYSDUMMY1"
      	testOnBorrow="true"                   
      	 url="jdbc:db2://<Accounts Database Server IP: Database
      	PORT>/<accounts_database_name>:driverType=4; currentSchema=<Schema_name>;
      	factory="com.jaspersoft.jasperserver.tomcat.jndi.JSCommonsBasicDataSourceFactory"/>

       

      <!-- For JasperReports Server 6.0 -->
      
      <!-- Add the following sample code for the Reports DB, to the existing context.xml --> 
      
      <Resource name="jdbc/onpremdb2" auth="Container"
      	type="javax.sql.DataSource"
      	maxActive="100" maxIdle="30" maxWait="10000"
      	username="<username>" password="<password>"
      	driverClassName="com.ibm.db2.jcc.DB2Driver"
      	validationQuery="SELECT 1 from SYSIBM.SYSDUMMY1"
      	testOnBorrow="true"                   
      	 url="jdbc:db2://<Reports Database Server IP: Database
      	PORT>/<reports_database_name>:driverType=4; currentSchema=<Schema_name>;
      	factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/>
      
      
      
      <!-- Add the following sample code for the Accounts DB, to the existing context.xml--> 
      
      <Resource name="jdbc/onpremdb2" auth="Container"
      	type="javax.sql.DataSource"
      	maxActive="100" maxIdle="30" maxWait="10000"
      	username="<username>" password="<password>"
      	driverClassName="com.ibm.db2.jcc.DB2Driver"
      	validationQuery="SELECT 1 from SYSIBM.SYSDUMMY1"
      	testOnBorrow="true"                   
      	 url="jdbc:db2://<Accounts Database Server IP: Database
      	PORT>/<accounts_database_name>:driverType=4; currentSchema=<Schema_name>;
      	factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/>
    • The following JNDI configuration is for the MSSQL:

      <!-- For JasperReports Server 8.0/7.1 -->
      
      <!-- Add the following sample code for the Reports DB, to the existing context.xml -->
      
      <Resource name="jdbc/onpremmssql" auth="Container" type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="<username>" password="<password>"
      	driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
              validationQuery="SELECT 1"
              testOnBorrow="true"
      	url="jdbc:sqlserver://<Reports Database Server IP: Database PORT>;databaseName=<reports_database_name>"
              factory="com.jaspersoft.jasperserver.tomcat.jndi.JSCommonsBasicDataSourceFactory"/>
      
      
      <!-- Add the following sample code for the Accounts DB, to the existing context.xml -->
      
      <Resource name="jdbc/onpremmssql" auth="Container" type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="<username>" password="<password>"
      	driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
              validationQuery="SELECT 1"
              testOnBorrow="true"
      	url="jdbc:sqlserver://<Accounts Database Server IP: Database PORT>;databaseName=<accounts_database_name>"
              factory="com.jaspersoft.jasperserver.tomcat.jndi.JSCommonsBasicDataSourceFactory"/>
      <!--For JasperReports Server 6.0 -->
      
      <!-- Add the following sample code for the Reports DB, to the existing context.xml --> 
      
      <Resource name="jdbc/onpremmssql" auth="Container" type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="<username>" password="<password>"
      	driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
              validationQuery="SELECT 1"
              testOnBorrow="true"
      	url="jdbc:sqlserver://<Reports Database Server IP: Database PORT>;databaseName=<reports_database_name>"
              factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/>
      
      
      <!-- Add the following sample code for the Accounts DB, to the existing context.xml --> 
      
      
      <Resource name="jdbc/onpremmssql" auth="Container" type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="<username>" password="<password>"
      	driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
              validationQuery="SELECT 1"
              testOnBorrow="true"
      	url="jdbc:sqlserver://<Accounts Database Server IP: Database PORT>;databaseName=<accounts_database_name>"
              factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/>
    • The following JNDI configuration is for the MySQL:
      
      //For JasperReports Server 8.0/7.1
      
      //Add the following Sample code for Reports DB for MySQL 
      
      
      <Resource name="jdbc/onpremmysql" auth="Container" type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="<username>" password="<password>"
              driverClassName="com.mysql.jdbc.Driver"
              validationQuery="SELECT 1"
              testOnBorrow="true"
      	url="jdbc:mysql://<Reports Database Server IP: Database PORT>/<reports_database_name>"
              factory="com.jaspersoft.jasperserver.tomcat.jndi.JSCommonsBasicDataSourceFactory"/>
      
      
      //Add the following Sample code for Accounts DB for MySQL 
      
      
      <Resource name="jdbc/onpremaccounts" auth="Container" type="javax.sql.DataSource"
      maxActive="100" maxIdle="30" maxWait="10000"
      username="root" password="******"
      driverClassName="com.mysql.jdbc.Driver"
      validationQuery="SELECT 1"
      testOnBorrow="true"
      url="jdbc:mysql://<Accounts Database Server IP: Database PORT>/<accounts_database_name>"
      factory="com.jaspersoft.jasperserver.tomcat.jndi.JSCommonsBasicDataSourceFactory"/>
      //For JasperReports Server 6.0
      
      //Add the following Sample code for Reports DB for MySQL 
      
      
      <Resource name="jdbc/onpremmysql" auth="Container" type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="<username>" password="<password>"
              driverClassName="com.mysql.jdbc.Driver"
              validationQuery="SELECT 1"
              testOnBorrow="true"
      	url="jdbc:mysql://<Reports Database Server IP: Database PORT>/<reports_database_name>"
              factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/>
      
      
      
      //Add the following Sample code for Accounts DB for MySQL
      
      <Resource name="jdbc/onpremaccounts" auth="Container" type="javax.sql.DataSource"
      maxActive="100" maxIdle="30" maxWait="10000"
      username="root" password="******"
      driverClassName="com.mysql.jdbc.Driver"
      validationQuery="SELECT 1"
      testOnBorrow="true"
      url="jdbc:mysql://<Accounts Database Server IP: Database PORT>/<accounts_database_name>"
      factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/>
      
    • The following JNDI configuration is for the Oracle:
      IMPORTANT:

      Based on your Oracle database version, select the following options:

      • If Oracle database is created with the PDB option of Oracle 12c, use service name pointing to PDB in the JDBC URL such as pdborcl or pdbmfdb.

        jdbc:oracle:thin:@<Database_Host_IP>:1521/pdbmfdb

        For example, jdbc:oracle:thin:@192.168.1.2:1521/pdbmfdb

      • If your database is either Oracle 11g or Oracle 12c without the PDB option, you can use ORACLE_SID in the JDBC URL such as orcl or mfdb.

        jdbc:oracle:thin:@<Database_Host_IP>:1521:mfdb

        For example, jdbc:oracle:thin:@192.168.1.2:1521:mfdb

      //Add the following Sample code for Reports DB, for Oracle.
      
      
      <Resource name="jdbc/onpremoracle" auth="Container"
      	type="javax.sql.DataSource"
      	maxActive="100" maxIdle="30" maxWait="10000"
      	username="<reportDatabaseName>" password="<password>"
      	driverClassName="oracle.jdbc.OracleDriver"
      	validationQuery="SELECT 1 from Dual"
      	testOnBorrow="true"
      	url="jdbc:oracle:thin:@ <Reports Database Server IP: Database
      	PORT>:Service_ID
             factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/> //Add the following Sample code for Accounts DB, for Oracle. <Resource name="jdbc/onpremoracle" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="<accountsDatabaseName>" password="<password>" driverClassName="oracle.jdbc.OracleDriver" validationQuery="SELECT 1 from Dual" testOnBorrow="true" url="jdbc:oracle:thin:@ <Accounts Database Server IP: Database PORT>:Service_ID
             factory="com.jaspersoft.jasperserver.tomcat.jndi.JSBasicDataSourceFactory"/>

      IMPORTANT: For versions of Oracle 12 c and earlier, where the database service ID is used instead of service name, use the following URL:
      "url="jdbc:oracle:thin:@ <Database Server IP: Database PORT>:<database_name>"

      IMPORTANT: If you are using the latest JasperReports Server V6.2 or higher, add a new JNDI configuration as custom dashboard feature is available in the latest package. The resource name value should be jdbc/onpremaccounts for all supported database types.

  3. Download appropriate database drivers for your database from the Jasper website link http://support.jaspersoft.com/download_preview.php?rl=60
  4. Add appropriate database drivers into the  \Jaspersoft\jasperreports-server-<8.0.0> or <7.1.0> or <6.2.0> or <6.0>\apachetomcat\lib folder.