Hi!
After specifying the datasource as you wrote you can look it up like this:
DataSource datasource;
Connection dsConnection;
try {
InitialContext ic = new InitialContext();
datasource = (DataSource)ic.lookup("java:/PostgresDS");
ds = datasource.getConnection();
} catch(Exception e) {
e.printStackTrace();
}
To be sure the name you are using to look it up is correct check it with
JNDIView. It's available at localhost:8082
alex
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Kotamraju, Srinivas, BmS- NY1540
> Sent: Wednesday, February 27, 2002 7:10 PM
> 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.X
> ADataSourceImp
> 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