• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

WebSphere 3.5 Connectio pool ??

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me on how to create a DataSource in WebSphere 3.5 and how to use the connection pool provided by websphere in my stateless session beans. When I tried to look up the DataSource, using JNDI lookup, it gave a ClassCastException for com.ibm.ejs.ns.jndi.CNContextImpl. How I shall give the database URL when I create a DataSource, and pl help me in finding out why this exception is coming
Thanks & Rgds
Praveen
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post your code and show us what exception you got...
Kyle
 
praveen p
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, The code segment which i used is the following.
public Connection getConnection() throws javax.ejb.EJBException, java.sql.SQLException {

InitialContext initCtx = null;
try {
initCtx = new InitialContext();
DataSource ds = (javax.sql.DataSource)initCtx.lookup("sba");
return ds.getConnection();
}catch(NamingException ne) {
System.out.println("Exception at getConnection() method in AttributeManagerBean class");
throw new EJBException(ne);
}finally {
try {
if(initCtx != null) initCtx.close();
}catch(NamingException ne) {
System.out.println("Error closing context: " + ne);
throw new EJBException(ne);
}
}
}
Here, 'sba' is the datasource name which is seen in the WebSphere admin console. I created a driver by name 'sba' and then installed it and created datasource. no the urlprefix is "jdbc b2"
Do I have to append the database server machine ip to this..? Please advice me whether my code is correct, and do I have to get an InitialContext object in the ejbCreate method.
In the above method, i tried to created an initial context in the following way too.
Properties h = new Properties();
h.put(javax.naming.Context.PROVIDER_URL,"iiop://localhost:900");
h.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
initCtx = new InitialContext(h);
When I try to use this getConnection() method from my servlet, its throwing the following exception(s)
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: com.ibm.ejs.container.UncheckedException: ; nested exception is: java.lang.ClassCastException: com.ibm.ejs.ns.jndi.CNContextImpl
Pl. do advice me how to proceed.
Thanks in advance
Praveen
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check whether you have included,
1) IBM Enterprise Extension Libraries and
2) IBM WebSphere Test Environment.
in your Class path ( preferably press "Select All" and include all in the class path.)
Second thing is try giving JNDI lookup name as

Regards
Ravindran.
[ February 19, 2002: Message edited by: ravindran shanmugam ]
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am also trying to use Connection Pooling using a simple java class in VAJ 3.5.
When I try to run the program, debugger opens with NoClassDefFoundError exception.
I am using the following code:-
javax.naming.InitialContext ctx =null;
javax.sql.DataSource ds =null;
Properties parms = new Properties();
try {
parms.put(Context.PROVIDER_URL,"iiop://localhost:900");
parms.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
ctx=new InitialContext(parms);
}
catch (Exception e) {
System.out.println("Exception= "+e);
}
try{
ds = (DataSource)ctx.lookup("jdbc/dbname");
Connection conn =ds.getConnection("scot","tiger");
}
catch (Exception e) {
System.out.println("Exception= "+e);
}
When I use the same code in a servlet, it runs fine. Can I use Connection pooling in simple class?
Regards,
kapil
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic