background image
<< Statement caching example | Embedded Mode and Network Server >>

XA and the Network Server

<< Statement caching example | Embedded Mode and Network Server >>
Derby Server and Administration Guide
29
// To dispose of the cache, close the connection.
pc.close();
XA and the Network Server
Both the Derby embedded driver and the Network Server provide XA support. The
Network Server provides DRDA level 7 support. DRDA clients that support XAMGR, such
as the Derby network client, can send XA requests to the Network Server.
Using XA with the network client driver
You can access XA support for the Network Server by using the network client driver's
XA DataSource interface.
The interface
org.apache.derby.jdbc.ClientXADataSource
is available on all
supported Java SE platforms. If your client runs on the Java SE 6 platform, and if you
want to use XA DataSource methods specific to the JDBC 4 API, use the DataSource
named
org.apache.derby.jdbc.ClientXADataSource40
.
If your client is running on the Java SE 6 platform, all connection objects returned from
the DataSource will be JDBC 4 connection objects, whether or not you are using the
DataSource whose name ends in "40".
The following example illustrates how to obtain an XA connection with the network client
driver:
import org.apache.derby.jdbc.ClientXADataSource;
import javax.sql.XAConnection;
...
XAConnection xaConnection = null;
Connection conn = null;
ClientXADataSource ds = new ClientXADataSource();
ds.setDatabaseName ("sample");
ds.setCreateDatabase("create");
ds.setServerName("localhost");
ds.setPortNumber(1527);
xaConnection = ds.getXAConnection("auser", "shhhh");
conn = xaConnection.getConnection();
Using the Derby tools with the Network Server
The Derby tools
ij
and
dblook
work in embedded mode and client/server mode.
Using the Derby ij tool with the Network Server
To use the ij tool with the network client driver:
1. Start ij in one of the following ways. For details, see "Starting ij" in the Derby Tools
and Utilities Guide.
a. Use a script.
Run the
ij.bat
script on Windows systems and the
ij
script on UNIX
systems. These scripts are located in the
$DERBY_HOME/bin
directory.
b. Run the ij tool using the
$DERBY_HOME/lib/derbyrun.jar
file.
java -jar derbyrun.jar ij
c. Run the ij tool by specifying the class name.
java org.apache.derby.tools.ij