JDBC Driver for SQL/MX Programmer's Reference
Autocommit Mode and Transaction Boundaries
When JDBC/MX manages the transactions, the driver decides to start a new transaction. A new
transaction is started when no transaction is associated with the Connection. When there is a
transaction associated with the Connection, that transaction is resumed. The Connection
attribute autocommit specifies when to end the transaction. Enabling autocommit causes the
JDBC/MX driver to end the transaction in accordance with the following rules:
The JDBC/MX driver rolls back the transaction for any SQL error in SQL statements other
than SELECT statements.
●
In the case of non-SELECT SQL statements, the JDBC/MX driver commits the transaction if
the current transaction was started for this SQL statement.
●
In the case of SELECT statements, the JDBC/MX driver commits the transaction at the time
of closing the result set.
●
In the case of concurrent multiple SELECT statements, the JDBC/MX driver commits the
transaction only when the result set of the SELECT statement or the statement that started the
transaction is closed.
●
Disabling Autocommit Mode
When the autocommit mode is disabled, the application must explicitly commit or roll back each
transaction by calling the Connection methods commit and rollback, respectively. When any
SQL error occurs in SQL statements other than SELECT statement, SQL/MX flags the transactions
for aborting. In such a case, the transaction is rolled back without regard to whether the application
commits or rolls back the transaction.
Stored Procedures
SQL/MX provides support for stored procedures, which are written in Java and run under an
SQL/MX execution environment.
Stored procedures can be run in SQL/MX by using the CALL statement. The JDBC/MX driver
allows stored procedures to be called by using the standard JDBC API escape syntax for stored
procedures. The escape SQL syntax is:
{call procedure-name([arg1,arg2, ...])}
where argn refers to the parameters sequentially, with the first parameter being arg1. For more
information about the non-escape syntax of the CALL statement, see the SQL/MX Reference
Manual.
Java applications can use the JDBC standard CallableStatement interface to run stored
procedures in SQL/MX by using the CALL statement. For further information, see the SQL/MX
Guide to Stored Procedures in Java.