Title: RE: [JBoss-user] jndi question
If you're referring to the usual JBoss datasource, cast it to javax.sql.DataSource.
 
hth
dim
----- Original Message -----
From: Jim
Sent: Tuesday, June 04, 2002 9:11 AM
Subject: [JBoss-user] connection pools, connecting to database.

Alright, after much searching I still haven't been able to get database access working correctly.
 
I am trying to access a database from a stateless session bean.  For performance, I would like the connections to be pooled.  In JBoss2.4.4, this involved setting up a few mbeans in the jboss.jcml file.
 
This is my old code, that does not work.  Casting exceptino on the (ConnectionPoolDataSource).  What should I cast it as?  Is my entire approach wrong?  Any tips or pointers to documentation I may have missed would be very much appreciated.
 
  try{
      InitialContext ctx = new InitialContext();
      System.out.println(ctx.lookup("java:/MySqlDS").toString());
      ConnectionPoolDataSource cpds =
        (ConnectionPoolDataSource)ctx.lookup("java:/MySqlDS");
       
 
      PooledConnection pc = cpds.getPooledConnection();
      conn = pc.getConnection();
    }catch(Exception e){
      System.out.println("Exception occured in Auth.ejbCreate()");
      System.out.println(e.toString());
     
    }
 
Thanks,

Jim
 

Reply via email to