12.11.2014 Views

web server - Borland Technical Publications

web server - Borland Technical Publications

web server - Borland Technical Publications

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

JDBC API Modifications<br />

JDBC API Modifications<br />

The standard Java Database Connectivity (JDBC) API is used by BES to access<br />

databases that support JDBC through vendor provided drivers. Requests for access to<br />

a database is centralized through the BES JDBC Connection Pool. This section<br />

describes modifications the BES JDBC pool makes to JDBC behavior for transactions.<br />

The JDBC pool is a pseudo JDBC driver that allows a transactional application to<br />

obtain a JDBC connection to a database. The JDBC pool associates JDBC<br />

connections with the Transaction Manager's transactions, and delegates connection<br />

requests to JDBC drivers that factory the JDBC connections. Once a connection is<br />

obtained using the JDBC pool, the transaction is coordinated automatically by the<br />

transaction service.<br />

The JDBC pool and its associated resources provide complete transactional access to<br />

the DBMS. The JDBC pool registers resources transparently with the transaction<br />

coordinator. Because of limitations of the 1.x version of the JDBC API, the JDBC pool<br />

can only provide one-phase commit. Version 2.0 of the JDBC API supports full twophase<br />

commit.<br />

Modifications to the behavior of the JDBC API<br />

Note<br />

To enable JDBC access for transactional applications written in Java, you use the<br />

JDBC API. The JDBC API is fully documented at the following <strong>web</strong> site:<br />

http://www.javasoft.com/products/jdk/1.2/docs/guide/jdbc/spec/jdbc-spec.frame.html<br />

However, the behavior of some JDBC methods is overridden by the partition's<br />

transaction service when they are invoked within the context of a transaction managed<br />

by the partition. The following methods are affected:<br />

■<br />

Java.sql.Connection.commit()<br />

■<br />

Java.sql.Connection.rollback()<br />

■<br />

Java.sql.Connection.close()<br />

■<br />

Java.sql.setAutoCommit(boolean)<br />

The rest of this section explains the changes to the semantics of these methods for<br />

partition-managed transactions.<br />

If a thread is not associated with a transaction, all of these methods will use the<br />

standard JDBC transaction semantics.<br />

Overridden JDBC methods<br />

Java.sql.Connection.commit()<br />

As defined in the JDBC API, this method commits all work that was performed on a<br />

JDBC connection since the previous commit() or rollback(), and releases all database<br />

locks.<br />

If a global transaction is associated with the current thread of execution do not use this<br />

method. If the global transaction is not a container-managed transaction, that is the<br />

application manages its own transactions, and a commit is required use the JTA API to<br />

perform the commit rather than invoking commit() directly on the JDBC connection.<br />

Java.sql.Connection.rollback()<br />

As defined in the JDBC API, this method rolls back all work that was performed on a<br />

JDBC connection since the previous commit() or rollback(), and releases all database<br />

locks.<br />

178 BES Developer’s Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!