You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Antony Paul <an...@hotmail.com> on 2003/11/15 13:50:13 UTC

DBCP - getting and closing connections and rollback()

Hello,
    I am using DBCP available with TOmcat 4.1.27. I use a static
synchronised method to get the connection from pool. In DBCP configuration
no parameter is setting the transaction status(setAutoCommit()). I want to
know what is happening when getting a connection from pool. Do I have to
call rollback()  before giving  the connection to client or do DBCP itself
does this. I feel that calling rollback() causes a performance penalty.

Antony Paul.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: DBCP - getting and closing connections and rollback()

Posted by John Zoetebier <jo...@transparent.co.nz>.
On Sat, 15 Nov 2003 18:20:13 +0530, Antony Paul <an...@hotmail.com> 
wrote:

> Hello,
>     I am using DBCP available with TOmcat 4.1.27. I use a static
> synchronised method to get the connection from pool. In DBCP 
> configuration
> no parameter is setting the transaction status(setAutoCommit()). I want 
> to
> know what is happening when getting a connection from pool. Do I have to
> call rollback()  before giving  the connection to client or do DBCP 
> itself
> does this. I feel that calling rollback() causes a performance penalty.

Once the DBCP connection pool is setup you can use a connection like you 
normally do.
There is absolutely no need to use a static method to get a connection 
 from the pool.
The connection pooling is completely transparent from a client point of 
view.
Suppose your pool is called "example".
Get you connection from pool with:
conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:example");

Send connection back to pool with:
conn.close()

All other connection methods work as usual:
conn.conn.setAutoCommit(true);
if (OK) {
	conn.commit();
} else {
	conn.rollback();
}

-- 
John Zoetebier
Web site: http://www.transparent.co.nz

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org