Java API and transactions

I get an error message somewhat like “method not supported by current implementation” when I use the methods BdXMLDB.beginTransaction() and BdXMLDB.endTransaction().

Is there really no support for transactions in the Java API?

Regards
Pascal Sch

Hi Pascal,

i guess the problem is that you not only have to open the database with the transaction flag set (BdXMLPersistencyFlags.BDXML_PF_TRANSACTIONS) but also you have to CREATE the database with that flag, since otherwise the database will not have transaction support.

If the database supports transactions a log file must exist, e.g. if your database is named database.bdbe the log file is named database.bdbe.log.

Regards
Ralf Stuckert

Thanks Ralf,

I made another mistake. I had to open the database with two flags set:
BdXMLPersistencyFlags.BDXML_PF_TRANSACTIONS |BdXMLPersistencyFlags.BDXML_PF_EAGER_TRANSACTIONS.

Regards
Pascal Sch

Hallo,

I still have got the problem with the following code snippet:

BdXMLDB db = null;
try {
db = BdXMLEnvironment.getEnvironment().
createXMLDatabase(“D:\Software AG\test.bdbe”,
BdXMLPersistencyFlags.BDXML_PF_TRANSACTIONS |
BdXMLPersistencyFlags.BDXML_PF_EAGER_TRANSACTIONS,0L);
db.beginTransaction(false);
db.abortTransaction();
}
catch (Exception exc) {
exc.printStackTrace();
}
finally {
db.close();
}

I get the exception:


com.birdstep.bdbe.xml.BdXMLException: The specified method is not supported by this interface.
at com.birdstep.bdbe.xml.jni.BdXMLDBNative.abortTransaction(Native Method)
at com.birdstep.bdbe.xml.jni.BdXMLDBImpl.abortTransaction(BdXMLDBImpl.java:32)


Is “abort transaction” currently not supported?

Regards
Pascal Sch

Hallo,

is it true that TM DB does not support transactions with more than one action like delete a document and after this, insert a new document, in a single transaction? I always get the error that the insert is not possible because there is still an active transaction.

Regards
Pascal Sch

Hi Pascal,

the “…not supported” message on abortTransaction() happens if the database does not support transactions. I already requested birdstep to throw an exception if you try to open a database with transaction flag and the database does not support this (because it was not created with transaction support).

Anyway even if you create and open the database correctly with transaction support, abortTransaction() currently has problems (if you close the database after abort, the JVM crashes). This will be fixed (hopefully) soon.

Another point is that some methods like importXML() implicitly use a transaction to perform their work, so if you have already opened a transaction you’ll receive an error. This will be added to the documentation (hopefully) soon.

Hope this helps
regards
Ralf