EasyManuals Logo

IBM DB2 User Manual

IBM DB2
585 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #90 background imageLoading...
Page #90 background image
Committing or rolling back JDBC transactions
In JDBC, to commit or roll back transactions explicitly, use the commit or rollback
methods.
For example:
Connection con;
...
con.commit();
If autocommit mode is on, the database manager performs a commit operation
after every SQL statement completes. To set autocommit mode on, invoke the
Connection.setAutoCommit(true) method. To set autocommit mode off, invoke the
Connection.setAutoCommit(false) method. To determine whether autocommit
mode is on, invoke the Connection.getAutoCommit method.
Connections that participate in distributed transactions cannot invoke the
setAutoCommit(true) method.
When you change the autocommit state, the database manager executes a commit
operation, if the application is not already on a transaction boundary.
While a connection is participating in a distributed or global transaction, the
associated application cannot issue the commit or rollback methods.
While a connection is participating in a global transaction, the associated
application cannot invoke the setAutoCommit(true) method.
Related concepts
“JDBC connection objects” on page 19
“Savepoints in JDBC applications” on page 57
Related tasks
“Making batch updates in JDBC applications” on page 28
“Disconnecting from data sources in JDBC applications” on page 99
Default JDBC autocommit modes
The default autocommit mode depends on the data source to which the JDBC
application connects.
Autocommit default for DB2 data sources
For connections to DB2 data sources, the default autocommit mode is true.
Autocommit default for IDS data sources
For connections to IDS data sources, the default autocommit mode depends on the
type of data source. The following table shows the defaults.
Table 19. Default autocommit modes for IDS data sources
Type of data source
Default autocommit mode
for local transactions
Default autocommit mode
for global transactions
ANSI-compliant database true false
Non-ANSI-compliant
database without logging
false not applicable
74 Application Programming Guide and Reference for Java

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM DB2 and is the answer not in the manual?

IBM DB2 Specifications

General IconGeneral
DeveloperIBM
Initial Release1983
LicenseProprietary
Written inC, C++
CategoryDatabase Management System (RDBMS)
Operating SystemLinux, Windows
Programming LanguagesC, C++
Data ModelsRelational
EditionsCommunity, Standard, Advanced
Key Featureshigh availability, scalability