-
2. Re: Configure and use Connection pool of Jboss
inderjeet Oct 23, 2006 11:51 PM (in response to inderjeet)Thanks for your reply........
one more thing i need to know that how can from my web application I can get a connection of the configured database?
Regards
Inder Jeet Singh -
3. Re: Configure and use Connection pool of Jboss
jaikiran Oct 24, 2006 12:02 AM (in response to inderjeet)Assuming that this is your datasource configuration:
<datasources> <local-tx-datasource> <jndi-name>MyAppDS</jndi-name> <connection-url>jdbc:oracle:thin:@youroraclehost:1521:yoursid</connection-url> ..... </datasources>
Note the jndi-name that you have specified for your datasource. The datasource will be bound to java:/MyAppDS jndi-name(in this example). From your web application, you can do a jndi lookup of this datasource, using the jndi-name that you have specified for the datasource, which will return you a Datasource object. You can then invoke the getConnection() method on the returned object. Something like:Context ctx = new InitialContext(); Datasource ds = ctx.lookup("java:/MyAppDS"); Connection conn = ds.getConnection();
-
4. Re: Configure and use Connection pool of Jboss
inderjeet Oct 30, 2006 6:33 AM (in response to inderjeet)I am done with "Getting connection from the JBoss connection pool". Now I would like to know that, after doing my database processiong, how can i return the connection back to the pool?
I have seen many example for JBoss connection pooling, but in all of then they have used the conn.close(). But according to me, we should not close the connection, instead we should return the connection back to the pool.
By closing the connection, we are actually beating the purpose of having a connection pool.
Am I Wrong? If I am not, then how to give the connection back to the pool?
Thanks & Regards
Inder Jeet Singh -
5. Re: Configure and use Connection pool of Jboss
jaikiran Oct 30, 2006 6:38 AM (in response to inderjeet)I have seen many example for JBoss connection pooling, but in all of then they have used the conn.close(). But according to me, we should not close the connection, instead we should return the connection back to the pool.
The internal implementation of the close() method takes care of returning it to the connection pool(Remember that java.sql.Connection is an interface and when you use connection pooling, the server will implement this interface to take care of returning the connection to the pool). So when you invoke the connection.close() method, you are actually returning the connection back to the pool. -
6. Re: Configure and use Connection pool of Jboss
inderjeet Oct 30, 2006 6:53 AM (in response to inderjeet)Oh, is it so..........
Then it is fine....
Thanks for ur prompt reply........