DEVFYI - Developer Resource - FYI

When I intersperse table creation or other DDL statements with DML statements ....

JDBC Interview Questions and Answers


(Continued from previous question...)

When I intersperse table creation or other DDL statements with DML statements ....

When I intersperse table creation or other DDL statements with DML statements, I have a problem with a transaction being commited before I want it to be. Everything ( commit and rollback ) works fine as long as I don't create another table. How can I resolve the issue?


While the questioner found a partially workable method for his particular DBMS, as mentioned in the section on transactions in my JDBC 2.0 Fundamentals Short Course:
DDL statements in a transaction may be ignored or may cause a commit to occur. The behavior is DBMS dependent and can be discovered by use of DatabaseMetaData.dataDefinitionCausesTransactionCommit() and DatabaseMetaData.dataDefinitionIgnoredInTransactions(). One way to avoid unexpected results is to separate DML and DDL transactions.
The only generally effective way to "rollback" table creation is to delete the table.

(Continued on next question...)

Other Interview Questions