New user's guide to BTM and JTA
JTA has the reputation of being hard to use and understand. This isn't true. There are a few new things you need to know but in general this information adds on top of your current JDBC or JMS experience.
Let's see what JTA hello, world! using BTM looks like. Here is a complete application's code that inserts a row in a Derby database using a JTA transaction and reads it back in another transaction:
This code expects a Derby database named db1 to be already created in the current folder with this table:
And this is what the application outputs when you run it:
Neat, huh? Who said using JTA is complex?
You can download this demo here: newUserDemo.zip.
There is an ant build.xml file included as well as a the necessary batch and shell scripts required to run the application from Windows or Unix.
Before you run the application, you have to create the Derby database. Just run the included derby-create.sh or derby-create.bat script to do so, it will create a directory called db1. Then you can start the demo by either running run.sh or run.bat.
Here is the list of JAR files with version required to run this demo. They're all included in the downloadable ZIP file.