Q: My database does not support transactions. What commit mode do I use in DOMToDBMS?

Applies to: 1.x

Databases that do not support transactions (such as MySQL) commit statements as they are executed. In XML-DBMS terms, this is COMMIT_AFTERINSERT -- that is, commit each insert immediately after it is executed. Thus, you should use the commit mode COMMIT_AFTERINSERT. This is the default commit mode, so you do not need to set it explicitly. However, you can call DOMToDBMS.setCommitMode(COMMIT_AFTERINSERT) if you want.

Note that using this commit mode results in two transaction-related calls:

A database that does not support transactions should support both of these calls, since they are the same as its current behavior. (The JDBC spec does not say what should be done here -- it requires databases to support transactions. However, I believe that ODBC, which is based on the same international standard, requires drivers to support both calls.)

If your database throws an exception:

Note that version 2.0 solves this problem by adding a COMMIT_NOTRANSACTIONS commit mode.

Back to the XML-DBMS FAQs