• 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

Probelm in connection pool

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I Configured connection pool in websphere . i has given datasource name test/anil.
Hashtable parms = new Hashtable();
parms.put Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
parms.put(javax.naming.Context.PROVIDER_URL, "iiop://websphere");
Context ctx = new InitialContext(parms);

DataSource ds = (DataSource)ctx.lookup("test/anil");
conn = ds.getConnection();
When i try to access the .jsp page it is giving error in websphere is
[03.08.13 10:10:41:786 GMT+05:30] 5932293d WebGroup X Servlet Error: : java.lang.NullPointerException
at Common.TestConnection_jsp_31._jspService(TestConnection_jsp_31.java:126)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:139)

plz give me the solution how to proceeds the next. what r all changes r requried to run properly
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"anil anil",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
With respect to your question, which line is throwing the exception? I think your JNDI connection information is suspect, try this instead:

Dave
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this, its working for me in WAS4,
Hashtable env = new Hashtable();
env.put( Context.INITIAL_CONTEXT_FACTORY , "com.ibm.websphere.naming.WsnInitialContextFactory");
javax.sql.DataSource ds =(javax.sql.DataSource)javax.rmi.PortableRemoteObject.narrow((new InitialContext()).lookup("DataSourceName"),javax.sql.DataSource.c
lass);
java.sql.Connection con = ds.getConnection();
java.sql.Statement stmt = con.createStatement();
java.sql.ResultSet rs = stmt.executeQuery("select * from tab");
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic