Home > Documentation > Apache Geronimo v1.1 - User's Guide > Administration > Configuring DB2 datasource |
This article shows you how to configure a DB2 datasource in Apache Geronimo v1.0. Normally you would just use the Geronimo Administration Console and the creation pool wizard for this task but that method allows you to specify only ONE driver jar file. In the case of DB2 you would have multiple files, one for the driver and two additional files for the license.
This article focuses on those tasks for manually adding the additional jar files to the datasource configuration.
To add the DB2 drivers and license to the Geronimo repository you will need to place those files in a particular directory structure. You will normally have three files to add to the repository, these files are:
These files are available in the <sqllib_home>\java directory. For additional information on the DB2 JDBC drivers and licenses visit the DB2 Information Center available at the following URL:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/topic/com.ibm.db2.udb.doc/ad/t0010264.htm
In order to use these files in Geronimo you will need to rename (copy and rename) as described in the following table.
Original name | Renamed |
---|---|
db2jcc.jar | db2jcc-8.1.8.jar |
db2jcc_license_cu.jar | db2jcc_license_cu-8.1.8.jar |
db2jcc_license_cisuz.jar | db2jcc_license_cisuz-8.1.8.jar |
This means that for this particular case DB2 v8.1.8.806 was used.
At this point you are ready to add those files to the Geronimo repository, to do that you have two alternatives. You can either use any graphical or command line tool to copy the files and create the necessary directories or you use the Geronimo Administration Console and add the driver and licenses to the common libraries. Next we will cover both alternatives.
You will need to create the following directory structures under the <geronimo_home>\repository
directory and copy the appropriate files to the respectives directories.
com/ibm/db2jcc/8.1.8
com/ibm/db2jcc_license_cisuz/8.1.8
com/ibm/db2jcc_license_cu/8.1.8
In order to use the console Apache Geronimo must be running. Access the Geronimo Administration Console by pointing your browser to the following URL:
With the drivers and license files installed you can now create a new database connection pool.
From the Geronimo Administration Console select Database Pools and create a new pool by clicking on Using the Geronimo database pool wizard.
On Step 1 of the create database pool wizard enter the pool name and database type as illustrated in the following figure and then click Next.
On Step 2 leave the JDBC Driver Class: field by default (com.ibm.db2.jcc.DB2Driver). If you click on the Driver JAR: pull-down menu you should now see the three com.ibm/db2... jars you copied in the repository. Since Geronimo v1.1 only allow you to select ONE jar file from this menu select the first jar on the list, com.ibm/db2jcc/8.1.8/jar which is the driver itself. You will add manually the license jars in the next steps.
Enter the remanining connection information as shown in the following figure. For this example the default db2admin user and password was used and a SAMPLE database was created via the DB2 Control Center.
Click Next.
Leave the options on Step 3 by default, you should see the message Driver Status: Loaded Successfully.
Click on Skip Test and Show Plan.
Copy the content of the Deployment Plan: and past it as a new db2-plan.xml file. You can save this file in a directory of your convenience, for simplicity (although not recommended) we saved this file to the <geronimo_home>\bin directory.
The deployment plan generated by the wizard is shown in the following example.
<?xml version="1.0" encoding="UTF-8"?> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.1"> <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1"> <dep:moduleId> <dep:groupId>console.dbpool</dep:groupId> <dep:artifactId>DB2_ds</dep:artifactId> <dep:version>1.0</dep:version> <dep:type>rar</dep:type> </dep:moduleId> <dep:dependencies> <dep:dependency> <dep:groupId>com.ibm</dep:groupId> <dep:artifactId>db2jcc</dep:artifactId> <dep:version>8.1.8</dep:version> <dep:type>jar</dep:type> </dep:dependency> </dep:dependencies> </dep:environment> <resourceadapter> <outbound-resourceadapter> <connection-definition> <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface> <connectiondefinition-instance> <name>DB2_ds</name> <config-property-setting name="Password">db2admin</config-property-setting> <config-property-setting name="Driver">com.ibm.db2.jcc.DB2Driver</config-property-setting> <config-property-setting name="UserName">db2admin</config-property-setting> <config-property-setting name="ConnectionURL">jdbc:db2://localhost:50000/SAMPLE</config-property-setting> <connectionmanager> <local-transaction/> <single-pool> <max-size>10</max-size> <min-size>0</min-size> <match-one/> </single-pool> </connectionmanager> </connectiondefinition-instance> </connection-definition> </outbound-resourceadapter> </resourceadapter> </connector>
Once you saved this deployment plan you can click on Cancel at the bottom left corner of the Database Pool portlet.
Edit the db2-plan.xml file you just created and add the dependencies for the license jar files as illustrated in the following example.
<?xml version="1.0" encoding="UTF-8"?> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.1"> <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1"> <dep:moduleId> <dep:groupId>console.dbpool</dep:groupId> <dep:artifactId>DB2_ds</dep:artifactId> <dep:version>1.0</dep:version> <dep:type>rar</dep:type> </dep:moduleId> <dep:dependencies> <dep:dependency> <dep:groupId>com.ibm</dep:groupId> <dep:artifactId>db2jcc</dep:artifactId> <dep:version>8.1.8</dep:version> <dep:type>jar</dep:type> </dep:dependency> <!-- Add db2jcc_license_cisuz license dependencies --> <dep:dependency> <dep:groupId>com.ibm</dep:groupId> <dep:artifactId>db2jcc_license_cisuz</dep:artifactId> <dep:version>8.1.8</dep:version> <dep:type>jar</dep:type> </dep:dependency> <!-- Add db2jcc_license_cu license dependencies --> <dep:dependency> <dep:groupId>com.ibm</dep:groupId> <dep:artifactId>db2jcc_license_cu</dep:artifactId> <dep:version>8.1.8</dep:version> <dep:type>jar</dep:type> </dep:dependency> </dep:dependencies> </dep:environment> <resourceadapter> <outbound-resourceadapter> <connection-definition> <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface> <connectiondefinition-instance> <name>DB2_ds</name> <config-property-setting name="Password">db2admin</config-property-setting> <config-property-setting name="Driver">com.ibm.db2.jcc.DB2Driver</config-property-setting> <config-property-setting name="UserName">db2admin</config-property-setting> <config-property-setting name="ConnectionURL">jdbc:db2://localhost:50000/SAMPLE</config-property-setting> <connectionmanager> <local-transaction/> <single-pool> <max-size>10</max-size> <min-size>0</min-size> <match-one/> </single-pool> </connectionmanager> </connectiondefinition-instance> </connection-definition> </outbound-resourceadapter> </resourceadapter> </connector>
To the deploy the DB2 datasource you just created run the following command from the <geronimo_home>\bin directory.
deploy --user system --password manager deploy db2-plan.xml ..\repository\tranql\tranql-connector\1.2\tranql-connector-1.2.rar
You should receive the following message:
E:\geronimo-1.1\bin>deploy --user system --password manager deploy db2-plan.xml ..\repository\tranql\tranql-connector\1.2\tranql-connector-1.2.rar Using GERONIMO_BASE: E:\geronimo-1.1 Using GERONIMO_HOME: E:\geronimo-1.1 Using GERONIMO_TMPDIR: E:\geronimo-1.1\var\temp Using JRE_HOME: C:\j2sdk1.4.2_09 Deployed console.dbpool/DB2_ds/1.0/rar
If you go back to the Database Pools portlet you should see the DB2_ds datasource listed in the portlet.
Bookmark this on Delicious Digg this | Privacy Policy - Copyright © 2003-2009, The Apache Software Foundation, Licensed under ASL 2.0. |