Kotamraju,

        I am not sure about the ConnectionPoolDataSource class, but if you
do a lookup against a pool created by the  org.jboss.jdbc.XADataSourceLoader
mbean, it returns an object that implements the javax.sql.DataSource
interface. 

        This snippet will look up a DataSource from the pool you have
configured, get a connection, then close it (which returns it to the pool).

        try {
            InitialContext initCtx = new InitialContext();
            ds = (DataSource)initCtx.lookup("java:/PostgresDS);
                Connection con = ds.getConnection();
                con.close();
        } catch (Exception e) {
                e.printStackTrace();
        }

        Good luck.
        Lucas McGregor, NovaLogic

-----Original Message-----
From: Kotamraju, Srinivas, BmS- NY1540
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 9:10 AM
To: '[EMAIL PROTECTED]'
Subject: [JBoss-user] connection pooling and jboss.jcml


hi all,
I am trying to configure jboss.jcml to create a connection pool and work
with my postgres database..
my question is what will be the context.lookup JNDI Name for the connection?
 ConnectionPoolDataSource cpds =
(ConnectionPoolDataSource)ctx.lookup("??????");
or, If this is not the procedure can someone please post the procedure for
creating a connection pool.
thanks

.
<mbean code="org.jboss.jdbc.XADataSourceLoader"
name="DefaultDomain:service=XADataSource,name=PostgresDB">
  <attribute
name="DataSourceClass">org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImp
l</attribute>
  <attribute name="PoolName">PostgresDS</attribute>             
  <attribute name="URL">jdbc:postgresql://localhost:5432/dev</attribute>
  <attribute name="JDBCUser">post</attribute>
  <attribute name="Password">post123</attribute>
  </mbean>

code to get the connection:

public static Connection getConnection() {

      Connection conn=null;
      try {
// initialize JNDI lookup parameters
            Context ctx = ManualJNDI.getInitialContext();
            System.out.println("got context");
            ConnectionPoolDataSource cpds =
(ConnectionPoolDataSource)ctx.lookup("");
            System.out.println("got datasource");

            PooledConnection pc = cpds.getPooledConnection();
             System.out.println("got pooledconnection");          
              conn = pc.getConnection();
              System.out.println("got connection1");

      }
      catch(Exception exception){
      exception.printStackTrace();
      }
      finally{
      return conn;
      }
  }

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to