Over a million developers have joined DZone.

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

·

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:

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

{{ parent.tldr }}

{{ parent.urlSource.name }}