SQL/MX 2.3.x to SQL/MX 3.0 Database and Application Migration Guide (H06.22+, J06.11+)

Considerations for upgrading to SQL/MX Release
3.0
HP NonStop SQL/MX 2.3.x to SQL/MX 3.0 Database and Application Migration Guide666210-002
2-12
Using the read-only transaction access mode
The following is an application code sample:
conn.setReadOnly(true);
PreparedStatement pstmt = null;
String sql = "select ORDER_AMT from ORDERTBL where ORDER_QTY
> 100 ";
pstmt = conn.prepareStatement(sql);
ResultSet rss = pstmt.executeQuery();
conn.setReadOnly(false);
stmt.executeUpdate("delete from ORDERTBL");
Set the transaction access mode to read-only using the
java.sql.Connection.setReadOnly (boolean readonly) method.
Prepare the SELECT statement in read-only transaction access mode.
Executing the compiled SELECT statement starts a read-only
transaction.
Then, change the transaction access mode to read-write by setting the connection
attribute read-only to FALSE.
The subsequent DELETE operation (WRITE operation) returns SQL error 8551
and file system error 757.
These errors are not returned in SQL/MX Release 2.x.
Note. If the transaction AUTOCOMMIT attribute is set to ON, or the connection attribute
autocommit is set to TRUE, fetching the result set completely or closing the result set
commits the transaction. The subsequent WRITE operation executes in a new
transaction. As a result, SQL error 8551 and file system error 757 are not returned.
Example 2:
This example is applicable to ODBC and JDBC T4 applications only.