65 lines
4.6 KiB
HTML
65 lines
4.6 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="concept" />
|
|
<meta name="DC.Title" content="Auto-commit mode" />
|
|
<meta name="abstract" content="By default, JDBC uses an operation mode called auto-commit. This means that every update to the database is immediately made permanent." />
|
|
<meta name="description" content="By default, JDBC uses an operation mode called auto-commit. This means that every update to the database is immediately made permanent." />
|
|
<meta name="DC.Relation" scheme="URI" content="transactions.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="transiso.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="savepnts.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="transaut" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>Auto-commit mode</title>
|
|
</head>
|
|
<body id="transaut"><a name="transaut"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Auto-commit mode</h1>
|
|
<div><p>By default, JDBC uses an operation mode called auto-commit. This
|
|
means that every update to the database is immediately made permanent. </p>
|
|
<p>Any situation where a logical unit of work requires more than one update
|
|
to the database cannot be done safely in auto-commit mode. If something happens
|
|
to the application or the system after one update is made and before any other
|
|
updates are made, the first change cannot be undone when running in auto-commit
|
|
mode.</p>
|
|
<p>Because changes are instantly made permanent in auto-commit mode, there
|
|
is no need for the application to call the commit method or the rollback method.
|
|
This makes applications easier to write.</p>
|
|
<p>Auto-commit mode can be enabled and disabled dynamically during a connection's
|
|
existence. Auto-commit is enabled in the following way, assuming that data
|
|
source already exists:</p>
|
|
<blockquote><pre>Connection connection = dataSource.getConnection();
|
|
|
|
Connection.setAutoCommit(false); // Disables auto-commit.</pre>
|
|
</blockquote>
|
|
<p>If the auto-commit setting is changed in the middle of a
|
|
transaction, any pending work is automatically committed. An SQLException
|
|
is generated if auto-commit is enabled for a connection that is part of a
|
|
distributed transaction. </p>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="transactions.htm" title="A transaction is a logical unit of work. To complete a logical unit of work, several actions may have to be taken against a database.">Transactions</a></div>
|
|
</div>
|
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
|
<div><a href="transiso.htm" title="Transaction isolation levels specify what data is visible to statements within a transaction. These levels directly impact the level of concurrent access by defining what interaction is possible between transactions against the same target data source.">Transaction isolation levels</a></div>
|
|
<div><a href="savepnts.htm" title="Savepoints allow the setting of "staging points" in a transaction. Savepoints are checkpoints that the application can roll back to without throwing away the entire transaction. Savepoints are new in JDBC 3.0, meaning that the application must run on Java Development Kit (JDK) 1.4 or a subsequent release to use them. Moreover, savepoints are new to the Developer Kit for Java, meaning that savepoints are not supported if JDK 1.4 or a subsequent release is not used with previous releases of the Developer Kit for Java.">Savepoints</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |