File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes get Connection from ConnectionPool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "get Connection from ConnectionPool" Watch "get Connection from ConnectionPool" New topic

get Connection from ConnectionPool

sai prasanna
Ranch Hand

Joined: May 02, 2005
Posts: 167
hi all,

How to get an Connection from an Connnection Pool is the following code correct.
Connection con=null;
con = ds.getConnection();

thanks in advance
Wei Dai
Ranch Hand

Joined: Jun 22, 2005
Posts: 86
ConnectionPoolDataSource ds;
PooledConnection con=ds.getPooledConnection();
Masoud Kalali
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

sai prasanna , you code is true in case that your datasource works ok , do not forget that you must close the connection after your job finished with the connection.

What Wei Dai said , must looks like the following one to works.

Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
I agree. Here's the link:
subject: get Connection from ConnectionPool
It's not a secret anymore!