You can now just create a InitialContext with the no-args constructor to have access to it.<=
/p>=20

API way: Creating the dat=
asources

=20

As you can expect, you will need to create one PoolingDataSource=
code> per database. Say that you want to use two Embedded Derby databases, =
and configure them via the BTM API. Here is what your code would look like:=

The BTM JNDI provider will automatically bind the datasources under thei=
r unique name. In this case, you can look up jdbc/testDS1 or jdbc/testDS2 a=
s soon as the transaction manager started without having anything else to c=
onfigure.

Resource Loade=
r way: Creating the datasources

=20

You can use BTM's Resource Loader instead of the BTM API. It is usually =
a good idea when you want to create a fully standalone application as you c=
an get rid of the datasources creation, JNDI binding and shutdown code.

=
=20

Create a datasources.properties file in the current directo=
ry containing these properties:

Say that persistUser() creates a new user, in no way will a user be created in one database and not in the other.

=20

Download

=20

You can download a sample runnable application putting these explanation=
s in practice. It contains all the code that has been skipped for clarity i=
n this page. Both the API and Resource Loader ways are implemented so you c=
an try both and see which one you prefer.

There is an ant build.xml file included as well as a th=
e necessary batch and shell scripts required to run the application from Wi=
ndows or Unix.

=20

Before you run the application, you have to create the Derby database. J=
ust run the included derby-create.sh or derby-crea=
te.bat script to do so, it will create two directories called users1 and users2. Then you can start the dem=
o by either running run_api.sh or run_api.bat for the API version, run_rl.sh or run_rl.bat<=
/strong> for the Resource Loader version.

=20

Here is the list of JAR files with version required to run this demo. Th=
ey're all included in the downloadable ZIP file.