11.2. Transactions in Java

Now that we have introduced the concept of a transaction and distributed transactions, let us now look at how transactions are supported and used in existing Java applications.

11.2.1. JDBC transactions

Java applications can include transactional constructs at different levels. An application interacting with a datastore using JDBC can use JDBC level transactions. A JDBC transaction is controlled by the transaction manager of the underlying datastore and is demarcated using the commit and rollback methods of the java.sql.Connection interface. For example:

 Connection conn =DriverManager.getConnection ("jdbc:oracle:thin:@jdo:Oracle"); conn.setAutoCommit(false); try{ Statement stmt = con.createStatement(); stmt.executeUpdate(" ...

Get Core Java™ Data Objects now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.