开发者

Java JDBC savePoint

Reading

http://download.oracle.com/javase/6/docs/api/java/sql/Savepoint.html

it is not well spelled out what savepoints are mapped from database perspective.

When savepoints are set, are the database changes made available to other transactions?

Than开发者_如何学编程ks


A savepoint marks a point that the current transaction can roll back to. Instead of rolling all of its changes back, it can choose to roll back only some of them. For example, suppose you:

  • start a transaction,
  • insert 10 rows into a table,
  • set a savepoint,
  • insert another 5 rows,
  • rollback to the savepoint,
  • commit the transaction.

After doing this, the table will contain the first 10 rows you inserted. The other 5 rows will have been deleted by the rollback.

Setting a savepoint doesn't 'save' any data to the database. It doesn't make database changes visible to any other transaction. A savepoint is just a marker that the current transaction can roll back to.


Savepoints are not a JDBC feature, they are a DBMS feature.

In addition to Luke's detailed answer you might also want to read up on what the DBMS manuals explain about savepoints

http://www.postgresql.org/docs/current/static/sql-savepoint.html
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_10001.htm#BABFIJGC
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0003271.html
http://msdn.microsoft.com/en-us/library/ms188378.aspx
http://dev.mysql.com/doc/refman/5.5/en/savepoint.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜