Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

How to use JTA transactions with BTM in Spring

This howto is intended for developers using Spring wanting to take advantage of distributed transactions when using JDBC code.

Spring and BTM versions used in this document:

  • Spring 2.x
  • BTM 1.0

Database used for this document:

  • Derby version

JDK version:

  • This requires JDK 1.5+


Project directory structure

Here are the folders you first need to create:

Below is a list of required jars. You have to copy them under the lib/ folder:

  • spring.jar
  • cglib-nodep-2.1_3.jar
  • btm-1.0.jar
  • commons-logging-1.0.4.jar
  • slf4j-jdk14.jar
  • geronimo-spec-jta-1.0.1B-rc4.jar
  • derby-
  • derbytools-

Derby configuration

You need to create two databases, each one with a single users table.

To do so, create the file PROJECT_HOME/derby-create.sql with this content:

Then run this command:

Configuring Spring

Create a file named beans.xml in the PROJECT_HOME/ folder with this content:

Test Code

Create these Java classes in the PROJECT_HOME/src/jtatest folder. Note: this code isn't anywhere near production ready - it's only supposed to be used as a simple test !

Now you have to run those commands from the PROJECT_HOME/ folder.

Compile these classes using this command line:

Lastly, run your application using this command line:

  • No labels