This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

registering a DB2 datasource in tomcat 5.5.4

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 4278
34
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Friend,

you found the solution for connecting db2 in tomcat? I have similar problem.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic