transactionBegin (Database - Java)

Begins recording changes to a database on a Domino server.

Defined in

Database

Syntax

Database.transactionBegin();

Usage

  • transactionBegin begins recording changes to a database. The changes take effect after a call to transactionCommit.
  • The transactionBegin call can be made from a server or from a client that accesses a database on a server.
  • Transaction logging must be enabled in the Domino Server document.
  • If any error occurs after transactionBegin is called, all changes are discarded.
  • Always call transactionCommit or transactionRollback prior to allowing the database to go out of scope or changes may be lost.
  • Multithreading is not supported within a transaction set. Change a database using a single thread.

Example

try {
Session session = getSession();
AgentContext ac = session.getAgentContext();
Database db = session.getDatabase("myserver", "mydb.nsf");
db.transactionBegin();
Document doc = db.createDocument();
doc.replaceItemValue("Form", "Memo");
doc.replaceItemValue("Subject", "TestDoc");
doc.save();
db.transactionCommit();
} catch(Exception e) {
	e.printStackTrace();
}