This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Connection Pooling and JDBC lookup. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection Pooling and JDBC lookup." Watch "Connection Pooling and JDBC lookup." New topic
Author

Connection Pooling and JDBC lookup.

Praveen Dharmavaram
Ranch Hand

Joined: Nov 05, 2002
Posts: 59
Hi,
I am trying to setup a connection pool and its not quite working the intended way. Here's the code which sort of works
***********************************************************************
Code that works with an exception
***********************************************************************
String poolName = "jdbc/aaa";
Hashtable parms = new Hashtable();
parms.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
InitialContext ctx = new InitialContext(parms);
DataSource dSource = ctx.lookup(poolName);
************************************************************************
I get a datasource but i do see an Info message
************************************************************************
ConnectionFac I J2CA0122I: Resource reference jdbc/VADDB2Dsrc could not be located, so default values of the following are used: [Resource-ref settings]
res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)
[Other attributes]
isCMP1_x: false (not CMP1.x)
isJMS: false (not JMS)
************************************************************************
Resource declaration in web.xml
************************************************************************
<resource-ref id="ResourceRef_1066407533296">
<res-ref-name>jdbc/aaa</res-ref-name>
<res-type>java.lang.object</res-type>
<res-auth>CONTAINER</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
************************************************************************I When i tried to get the datasource by doing
Datasource dSource = ctx.lookup("java:comp/env/jdbc/aaa");
I got an Naming Exception doing that.
************************************************************************
Naming Exception
************************************************************************
[10/17/03 12:25:33:141 EDT] 5db6bcbf SystemErr R javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
[10/17/03 12:25:33:141 EDT] 5db6bcbf SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1638)
[10/17/03 12:25:33:141 EDT] 5db6bcbf SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:997)
[10/17/03 12:25:33:141 EDT] 5db6bcbf SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:920)
[10/17/03 12:25:33:141 EDT] 5db6bcbf SystemErr R at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1211)
[10/17/03 12:25:33:141 EDT] 5db6bcbf SystemErr R at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1203)
[10/17/03 12:25:33:141 EDT] 5db6bcbf SystemErr R at com.ibm.ws.naming.urlbase.UrlContext.lookup(UrlContext.java:1257)
[10/17/03 12:25:33:141 EDT] 5db6bcbf SystemErr R at javax.naming.InitialContext.lookup(InitialContext.java:359)
[10/17/03 12:25:33:141 EDT] 5db6bcbf SystemErr R at com.ibm.annap.test.TestServlet.getDataSource(TestServlet.java:108)
[10/17/03 12:25:33:359 EDT] 5db6bcbf SystemErr R at com.ibm.annap.test.TestServlet.doPost(TestServlet.java:49)
[10/17/03 12:25:33:359 EDT] 5db6bcbf SystemErr R at com.ibm.annap.test.TestServlet.doGet(TestServlet.java:32)
[10/17/03 12:25:33:359 EDT] 5db6bcbf SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
[10/17/03 12:25:33:375 EDT] 5db6bcbf SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[10/17/03 12:25:33:375 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[10/17/03 12:25:33:375 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[10/17/03 12:25:33:375 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[10/17/03 12:25:33:375 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[10/17/03 12:25:33:375 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
[10/17/03 12:25:33:375 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[10/17/03 12:25:33:375 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[10/17/03 12:25:33:375 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
[10/17/03 12:25:33:391 EDT] 5db6bcbf SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
[10/17/03 12:25:33:406 EDT] 5db6bcbf SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

************************************************************************
Any thoughts are appreciated.
Thanks
Praveen
Rohit Lal
Greenhorn

Joined: Sep 25, 2003
Posts: 20
Hi,
Is your client accessing the server from outside the server's context? If it isn't then no properties need to be provided. But it seems in your case that you are accessing the server from outside it's context. In that case, you would have to provide a second property - Context.PROVIDER_URL which basically specifies an IIOP/Corba based URL from which your client will be able to locate the datasource.
The link provided below will show you examples:
http://publib7b.boulder.ibm.com/wasinfo1/en/info/ae/ae/rnam_example_prop2.html
Regards,
Rohit Lal


Rohit Lal<br />SCPJ2 (2000)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection Pooling and JDBC lookup.
 
Similar Threads
Probelms with JNDI references
Calling a BMP Entity Bean 2.0 From the Web Module..WSAD 5.1.1
Calling a BMP Entity Bean 2.0 From the Web Module
JNDI Connection Pool problem with WAS 5.0.2 and Teradata
login error using WSAD5.1 & Oracle