| Sun Java System Application Server |
This sample application demonstrates using JDBC transactions. It consists of an EJB and a Java client.
A JDBC transaction is controlled by the transaction manager of the database server.
You may want to use JDBC transactions when wrapping legacy code inside a session bean.
To code a JDBC transaction, you invoke the commit and rollback methods of the
java.sql.Connection interface. The beginning of a transaction is implicit.
A transaction begins with the first SQL statement that follows the most recent commit,
rollback, or connect statement. This is generally true, but may vary with database vendor.
To better understand the sample application source code, generate and read the Javadoc, as described in Building, Deploying, and Running Sample Applications.
Before you deploy or run the application, you must ensure that a database resource has been configured for
Application Server. The included asant deployment script automatically performs this step for you.
But if you are using another deployment mechanism, you must perform it manually.
You can use any JDBC-compliant relational database server, but specific instructions are provided for the following:
The general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:
install_dir is the directory where Application Server is installed.
app_dir is the application base directory:
install_dir/samples/jdbc/apps/transactions.
jdbc-transactions.ear.
Follow this general procedure:
build.xml, is in the app_dir directory,
specifically, install_dir/samples/jdbc/apps/transactions.
install_dir/samples/jdbc/apps/transactions/jdbc-transactions.ear.
NOTE: Do not undeploy this application if you are running the jdbc-simple application.
The Ant build file pre-populates the database tables, so you don't need to configure the database.
When you deploy the application with Ant, it creates
the JDBC connection pool and corresponding JDBC resource.
To understand how the Ant script creates these resources, see the build.xml file.
After the application is deployed, run the application client JAR file in the application client container as follows:
cd app_dir appclient -client jdbc-transactionsClient.jar
The appclient executable is in install_dir/bin.
The client will display the following:
status = shipped
Run asant undeploy before redeploying this application.
This ensures that all modules are undeployed and the resources are disabled.
Copyright © 2006 Sun Microsystems, Inc. All rights reserved.