Example 2: Using JNDI data source connections of JBoss server

Using JBoss as an example, in this Example, DB2 is used, and JBoss is installed to D:\jboss-4.0.1, take the following steps:

  1. Copy the DB2 driver to D:\jboss-4.0.1\server\default\lib.
  2. Create a db2-ds.xml file in D:\jboss-4.0.1\server\default\deploy, and add the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <datasources>
        <local-tx-datasource>
            <jndi-name>DB2DataSource</jndi-name>
            <connection-url>jdbc:db2://dbs-b/sample</connection-url>
            <driver-class>com.ibm.db2.jdbc.net.DB2Driver</driver-class>
            <user-name>db2admin</user-name>
            <password>db2admin</password>
            <min-pool-size>0</min-pool-size>
            <metadata>
                <type-mapping>DB2</type-mapping>
            </metadata>
        </local-tx-datasource>
    </datasources>
  3. Modify datasource.xml in <install_root>\bin. Make sure that the following are included:
    <datasource-mapping>
        <datasource>
            <catalog-connection-name>ConnectionName</catalog-connection-name>
            <connection-type>JNDI</connection-type>
            <jndi-datasource>java:/DB2DataSource</jndi-datasource>
        </datasource>
    </datasource-mapping>
  4. Build the JReport Server WAR file using the makewar.bat utility in the <install_root>\bin directory.
  5. Deploy JReport Server to JBoss.
  6. Run the report that uses this connection.