Learn XQuery |
Home:Learn XQuery:XQuery Examples:XQuery Updates:Transactional Behavior Understanding the Transactional Behavior of DataDirect XQuery UpdatesThis section describes how DataDirect XQuery supports transactions, transaction isolation levels, and distributed transactions. TransactionsA transaction consists of one or more updating XQueries that have been executed, completed, and then either committed or rolled back. By default, a DataDirect XQuery connection (a new XQConnection object) is in auto-commit mode. Auto-commit causes a commit after each XQuery is evaluated. To disable auto-commit, specify false as the argument value for setAutoCommit(), which is a method of the XQConnection interface. For example: ... DDXQDataSource ds = new DDXQDataSource(); ds.setJdbcUrl("jdbc:xquery:sqlserver://server1:1433;databaseName=stocks"); XQConnection conn = ds.getConnection("myuserid", "mypswd"); conn.setAutoCommit(false); ... When auto-commit is disabled, the application must either commit each transaction explicitly or roll back each transaction explicitly. When a connection is closed, DataDirect XQuery, by default, rolls back the active transaction. To perform commits and rollbacks, use the commit() and rollback() methods, respectively, of XQConnection. . Transaction Isolation LevelsDataDirect XQuery supports the isolation levels as defined in the JDBC interface java.sql.Connection, which are as follows:
The database to which you are connecting may not support all of these isolation levels, as detailed in following table.
The names of the DB2 isolation levels do not map one-to-one to the names of the JDBC isolation levels. The following table maps the JDBC isolation levels to the appropriate DB2 isolation levels.
To set an isolation level for a single connection, specify the appropriate value for the JdbcTransactionIsolationLevel property of DDXQDataSource. To set an isolation level for multiple connections, specify the appropriate value for the TransactionIsolationLevel property of DXQJDBCConnection. NOTE: Once a connection is made, the transaction isolation level cannot be changed for that connection (XQConnection object). Distributed TransactionsDataDirect XQuery does not support distributed transactions. However, it is possible to have a single DataDirect XQuery connection (XQConnection object) with multiple underlying JDBC connections and perform updates if the updates target only one of the JDBC data sources. It is, also, possible during the lifetime of an XQConnection object to update two different JDBC data sources if this is done in separate transactions (not in a single transaction). |
||||||||||||||||||||||||||||||





