Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

[Java] Read DataSource From Connection Pool (Tomcat And WAS4)

DZone's Guide to

[Java] Read DataSource From Connection Pool (Tomcat And WAS4)

·
Free Resource

Context initContext;
initContext = new InitialContext();
DataSource ds = null;

if ("TOMCAT".equals(appServer)) {

      //Apache Tomcat Server
      ds = (DataSource)initContext.lookup("java:comp/env/jdbc/yourJNDI");

} else if  ("WAS4".equals(appServer)) {

      //IBM WebSphere 4.x
      ds = (DataSource)initContext.lookup("jdbc/yourJNDI");
                                
}
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}