Vera,

This should be pretty straightforward.  Assuming you're using the latest
version of Torque, you'll notice that most calls that retrieve data have
two versions - one that takes a java.sql.Connection object and one that
doesn't.

If you want to use transactions, you need to use the versions that pass
in the Connection object.    And then you have the usual semantics for
commit and rollback.

Begining transactions is simply a case of getting a Connection from
Torque - and that is done by:

Connection conn = Torque.getConnection();

And then return the connection via Torque.releaseConnection(conn);

BE SURE TO RETURN THE CONNECTION TO THE POOL WHEN YOU'RE DONE!
Usually, the best way to do this something like:

try
{
  Connection conn = Torque.getConnection();

}
finally
{
   try
   {
     Torque.releaseConnection(conn);
    }
    catch (TorqueException e)
    {
      // log the error - but generally we ignore 
      // this case
     }
}

By placing the Release connection in the finally block, you are
guaranteed that you won't get connection leaks - remember, Torque uses a
connection pool and if you don't return a connection, it will linger
unused and eventually you'll run out connections in your pool.

-Peter
On Fri, 2002-10-18 at 10:03, Vera Neupert wrote:
> Hello,
> 
> does anybody knows how I could manage my own Transactions. How to begin,
> commit and rollback.
> 
> Vera



--
To unsubscribe, e-mail:   <mailto:turbine-torque-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-torque-user-help@;jakarta.apache.org>

Reply via email to