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();

Upcoming Training Events

0 AM
Visual Studio Live! San Diego
September 8-12, 2025
Live! 360 Orlando
November 16-21, 2025
Cloud & Containers Live! Orlando
November 16-21, 2025
Data Platform Live! Orlando
November 16-21, 2025
Visual Studio Live! Orlando
November 16-21, 2025