SQL/MX Programming Manual for Java
SQL/MX Programming Considerations
HP NonStop SQL/MX Programming Manual for Java—523726-003
4-44
Setting Attributes for Transactions
•
Calling the setAutoCommit() method of the java.sql.Connection interface:
For an implicit connection context:
java.sql.Connection conn = 
DefaultContext.getDefaultContext().getConnection();
conn.setAutoCommit(false);
For an explicit connection context named ctx:
ctx.getConnection().setAutoCommit(false);
For information about setAutoCommit(), see the JDBC Driver for SQL/MX 
Programmer’s Reference. For information about implicit and explicit connection 
contexts, see Connection Contexts on page 3-8.
Isolation Level Setting
The isolation level specifies the level of data consistency defined for the transaction 
and the degree of concurrency the transaction has with other transactions that use the 
same data. The isolation level of a transaction can be READ UNCOMMITTED, READ 
COMMITTED, or SERIALIZABLE (or REPEATABLE READ). For more information, see 
the SQL/MX Reference Manual.
In an SQLJ program, avoid using the SET TRANSACTION ISOLATION LEVEL 
statement because:
•
It always starts a compiler process.
•
It could cause automatic recompilation.
•
It could adversely affect UPDATE, INSERT, and DELETE statements in 
subsequent transactions.
The SET TRANSACTION ISOLATION LEVEL statement, regardless of whether it was 
statically compiled, always executes dynamically and applies its setting at run time. 
Therefore, this statement always starts a compiler process. To avoid performance 
costs, use a CONTROL QUERY DEFAULT ISOLATION_LEVEL statement instead. For 
more information about coding CONTROL statements, see CONTROL Statements on 
page 4-6.
The SET TRANSACTION ISOLATION LEVEL statement could cause automatic 
recompilation of DML statements in the next transaction. If a DML statement is 
statically compiled and does not specify an explicit access option (for example, READ 
COMMITTED, SERIALIZABLE, and so on), its access option at compile time is 
determined by the ISOLATION_LEVEL setting, if present, or by the system-defined 
isolation level, which is READ COMMITTED. If SQL/MX executes the DML statement 
after executing a SET TRANSACTION ISOLATION LEVEL statement with a different 
isolation level setting, the SQL/MX executor automatically recompiles the DML 
statement. To avoid automatic recompilation, specify explicit access options in 
individual DML statements. The access options in DML statements override the 










