Local transactions using JDBC 2.0 API
- By Salih Ergul
- February 5, 2001
ENTERPRISE JAVA
Transaction Processing With Java
Salih Ergül
Listing 1. Local transactions using JDBC 2.0 API.
// First get a connection, assuming that ds is of type
// DataSource
Connection con = ds.getConnection(...);
// Do all the work as a single transaction
con.setAutoCommit(false);
// The actual work goes here. You can query and update
// multiple tables in the database
// Commit the transaction
con.commit();
// Close the connection
con.close();
About the Author
Salih Ergül is a graduate student at the Technical University of Vienna, Austria. Salih specializes in distributed object/component systems. He can be contacted at [email protected].