theprofessorx
Programmer
Hello Developers.
I'm running the following:
- Tomcat 4
- SDK 1.3
- DB2 UDB 7
- Windows NT
I'm trying to configure Tomcat to set up a DB2 data source by using the following (relevant portions of code):
server.xml
<Context path="/transact" docBase="transact"
debug="0" reloadable="true">
<Resource name="jdbc/dbtransact" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/dbtransact">
<parameter>
<name>user</name>
<value>ADMIN</value>
</parameter>
<parameter>
<name>password</name>
<value>itsasecret</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>COM.ibm.db2.jdbc.app.DB2Driver</value>
</parameter>
<parameter>
<name>driverName</name>
<value>jdbc:db2://localhost:50000/TRANSDB</value>
</parameter>
</ResourceParams>
</Context>
web.xml (of transact application)
<res-ref-name>
jdbc/dbtransact
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
connect.java
Context ctx = new InitialContext() ;
Context envCtx = (Context) ctx.lookup("java:comp/env"
DataSource ds = (DataSource)envCtx.lookup("jdbc/dbtransact"
Connection con = ds.getConnection();
When connect.class is run, the following exception is thrown:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
I believe this error occurs at ctx.lookup.
Any help, advice, and/or suggestions would be very much appreciated. Thanks!!
I'm running the following:
- Tomcat 4
- SDK 1.3
- DB2 UDB 7
- Windows NT
I'm trying to configure Tomcat to set up a DB2 data source by using the following (relevant portions of code):
server.xml
<Context path="/transact" docBase="transact"
debug="0" reloadable="true">
<Resource name="jdbc/dbtransact" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/dbtransact">
<parameter>
<name>user</name>
<value>ADMIN</value>
</parameter>
<parameter>
<name>password</name>
<value>itsasecret</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>COM.ibm.db2.jdbc.app.DB2Driver</value>
</parameter>
<parameter>
<name>driverName</name>
<value>jdbc:db2://localhost:50000/TRANSDB</value>
</parameter>
</ResourceParams>
</Context>
web.xml (of transact application)
<res-ref-name>
jdbc/dbtransact
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
connect.java
Context ctx = new InitialContext() ;
Context envCtx = (Context) ctx.lookup("java:comp/env"
DataSource ds = (DataSource)envCtx.lookup("jdbc/dbtransact"
Connection con = ds.getConnection();
When connect.class is run, the following exception is thrown:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
I believe this error occurs at ctx.lookup.
Any help, advice, and/or suggestions would be very much appreciated. Thanks!!