|
|
Here are the steps for creating a Data Source on Tomcat:
-
In Tomcat's context.xml file (/conf/context.xml), add a line similar to the following:
<ResourceLink global="jdbc/MY_DATA_SOURCE_NAME" name="jdbc/MY_DATA_SOURCE_NAME" type="javax.sql.DataSource"/>
-
In Tomcat's server.xml file (/conf/server.xml, add the following XML snippet to the node:
<Resource name="jdbc/MY_DATA_SOURCE_NAME"
type="javax.sql.DataSource"
password="welcome"
driverClassName="com.ibm.db2.jcc.DB2Driver"
maxIdle="2" maxWait="5000"
validationQuery="select * from qauser.employee"
username="qauser"
url="jdbc:db2://qadb2v8:50000/QADATA"
maxActive="4" />
-
In Tomcat's common/lib directory, add the JDBC driver JARs (for DB2 v8.x or 9.x, these are db2jcc.jar, db2jcc_license_cu.jar, and
db2jcc_license_cisuz.jar). If connecting to DB2 v7, use the db2java.jar driver instead. You actually only need one of those license JARs. The "cu" JAR is for windows, the "cisuz" JAR is for UNIX, etc.
-
In your project's WebContent\WEB-INF\bin\deployment find the standalone.web.xml and edit it. Add the following xml just before the closing tag:
<resource-ref>
<description>DB2 example</description>
<res-ref-name>jdbc/SAMPLEShared</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
|