I'm a relative new WAS geek, so this should be a pretty easy answer. I've successfully connected to a DB2 system using the DriverManager API, however I want to take advantage of the Connection Pooling that WAS provides. I'm working with WAS Studio 4.0, WAS AE 4.0, and DB2v7.2. I've included some of the suspect code (which I've tried numerous variants), the successful DumpNameSpace results off of the server, and one of the failure entries from the server captured by the Log Analysis tool.
Thanks in advance,
Clint
'''''''''''''''''''''''''''''''''''''''''''
Here's the code from a suspect
JSP. I've tried numerous was to get the JNDI reference. I have also tried the lookup from a
servlet, tried the "tsx" tags, etc.
'''''''''''''''''''''''''''''''''''''''''''
try {
//Retrieve a DataSource through the JNDI Naming Service
Properties parms = new Properties();
parms.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
//Create the Initial Naming Context
Context ctx = new InitialContext(parms);
//Lookup through the naming service to retrieve a DataSource object
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/CRM");
//Obtain a Connection from the DataSource
conn = ds.getConnection();
//query the database
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM WASAdmin.Candidates");
} catch (java.sql.SQLException sqle) {
//handle SQLException
}
'''''''''''''''''''''''''''''''''''''''''''
This is from the WAS Studio Server Console during the WAS
Test Environment start up. No errors occur.
'''''''''''''''''''''''''''''''''''''''''''
[02.01.24 09:28:40:087 CST] 5583d308 ResourceBinde I WSVR0049I: Binding CRM as jdbc/CRM
'''''''''''''''''''''''''''''''''''''''''''
Here's the output from the DumpNameSpace on the Server when ran on the server. It correctly has the "jdbc/CRM" entry.
'''''''''''''''''''''''''''''''''''''''''''
C:\WebSphere\AppServer\bin>dumpnamespace -startAt
jdbc Getting the initial context
Getting the starting context
====================================================================================
Name Space Dump
Provider URL:
iiop://localhost:900 Context factory: com.ibm.websphere.naming.WsnInitialContextFactory
Requested root context: legacy
Starting context: (top)=jdbc
Formatting rules: jndi
Time of dump: Thu Jan 24 09:50:29 CST 2002
====================================================================================
====================================================================================
Beginning of Name Space Dump
====================================================================================
1 (top)
2 (top)/eStaffDS com.ibm.ejs.cm.portability.PortableDataSource
3 (top)/SampleDataSource com.ibm.ejs.cm.portability.PortableDataSource
4 (top)/CRM com.ibm.ejs.cm.portability.PortableDataSource
5 (top)/sample com.ibm.ejs.cm.portability.PortableDataSource
====================================================================================
End of Name Space Dump
====================================================================================
'''''''''''''''''''''''''''''''''''''''''''
Here is a dump from the Log Analysis tool
'''''''''''''''''''''''''''''''''''''''''''
RecordId:Rec_325
ComponentId:
ProcessId:2164
ThreadId:7f98d66c
FunctionName:
ProbeId:
SourceId:com.ibm.ws.naming.util.Helpers
Manufacturer:IBM
Product:WebSphere
Version:AE 4.0.1 a0131.07
ServerName:websphere/Default Server
ClientHostName:
ClientUserId:
TimeStamp:1/24/2002 9:56:50.593000000
UnitOfWork:
Severity:3
Category:AUDIT
FormatWarning:
PrimaryMessage:
ExtendedMessage: NMSV0610I: A NamingException is being thrown from a javax.naming.Context implementation. Details follow:
Context implementation: com.ibm.ws.naming.java.javaURLContextRoot
Context method: lookup(Name)
Context name:
java:
Target name: comp/env/jdbc/CRM
Other data:
Exception stack trace: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1443)
at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:824)
at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1166)
at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1158)
at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1210)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at test2_jsp_0._jspService(test2_jsp_0.java:97)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:139)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:286)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:415)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:544)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:159)
at com.ibm.servlet.engine.webapp.ServicingServletState.service(StrictLifecycleServlet.java:306)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:106)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:499)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:278)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:105)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:67)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:123)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:122)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:315)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:313)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:242)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:122)
RawDataLen:0
RawData: