File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes registering a DB2 datasource in tomcat 5.5.4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "registering a DB2 datasource in tomcat 5.5.4" Watch "registering a DB2 datasource in tomcat 5.5.4" New topic

registering a DB2 datasource in tomcat 5.5.4

dileep sivaraman

Joined: Jul 30, 2007
Posts: 1
Hi ,

I am trying to register a db2 datasource in tomcat 5.5.4. However I get null when I do context.lookup in my java code.

This is what i have done


<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase" pathname="conf/tomcat-users.xml" factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>

<Resource type="" name="jdbc/db5" factory="" driverClassName="" />



<ResourceLink global="jdbc/db5" name="jdbc/db5" type=""/>

Java code :

Context initialContext = new InitialContext();
Context envContext = (Context)initialContext.lookup("java:comp/env");
Object lookedUpObject = envContext.lookup("jdbc/db5");
System.out.println("db class loader >>>>>>>> :"+lookedUpObject);


db class loader >>>>>>>> :null
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3738

Correct me if I'm wrong, but can't you use Tomcat's admin login tool to view a list of all data sources? After you have found it in the list, it should have the precise JNDI string that will load the application.

[OCA 8 Book] [Blog]
Gaston Quezada

Joined: Apr 02, 2008
Posts: 2

you found the solution for connecting db2 in tomcat? I have similar problem.
I agree. Here's the link:
subject: registering a DB2 datasource in tomcat 5.5.4