• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connection Pooling and JDBC lookup.

 
Ranch Hand
Posts: 59
  • 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 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
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic