• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

registering a DB2 datasource in tomcat 5.5.4

 
dileep sivaraman
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Saloon Keeper
Posts: 4020
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gaston Quezada
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friend,

you found the solution for connecting db2 in tomcat? I have similar problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic