aspose file tools*
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
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
Author

registering a DB2 datasource in tomcat 5.5.4

dileep sivaraman
Greenhorn

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

Server.xml

<GlobalNamingResources>
<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="COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource" name="jdbc/db5" factory="com.ibm.db2.jcc.DB2DataSourceFactory" driverClassName="com.ibm.db2.jcc.DB2Driver" />

</GlobalNamingResources>


context.xml


<ResourceLink global="jdbc/db5" name="jdbc/db5" type="COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource"/>


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);


Output

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

Joined: Oct 23, 2005
Posts: 3704
    
    5

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.


My Blog: Down Home Country Coding with Scott Selikoff
Gaston Quezada
Greenhorn

Joined: Apr 02, 2008
Posts: 2
Friend,

you found the solution for connecting db2 in tomcat? I have similar problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: registering a DB2 datasource in tomcat 5.5.4