Local transactions using JDBC 2.0 API

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 salih.ergul@usa.net.

Featured

Most   Popular
Upcoming Events

AppTrends

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.