1 Reply Latest reply on Nov 25, 2009 9:58 AM by JoshDBoyle

    Transaction Management using JDBC service

    Amit Gadkari Level 1

      In Adobe Livecycle 8.2 JDBC service do not provide exception handling.

       

      How to start trasaction from client Java application running on another machine and pass it to customised process having JDBC service

       

      Should transaction be started on client machine using JNDI lookup of Transaction manager of Livecycle application server

      How to rollback transaction when Java application get error from EJB end point.

        • 1. Re: Transaction Management using JDBC service
          JoshDBoyle Level 1

          Hello Amit!

           

          It is true that LiveCycle 8.2's JDBC service has on built-in exception handling.  This has been remedied in 9.0 as there are now several exception types that can be handled.

           

          If I understand correctly, your trouble comes with the lack of transaction management around the existing JDBC service within LiveCycle.  To this I can only recommend that any SQL statements needing to be run with transaction management be done so within an executeScript service.  I have, on many, many occasions, utilized this service to write some custom code using the Statement and/or PreparedStatement classes to handle any database interactions.

           

          In addition to the above, it seems as though you would like to leverage the JNDI lookup capability of LiveCycle's JDBC service so you can specify a data source name as opposed to having to establish your own connection.  This too can be handled within the executeScript service via custom code.  As an example, the following code, when dropped in an executeScript service, will establish a connection to an Oracle database via JNDI lookup:

           

          import oracle.sql.*;

          import java.sql.Connection;

          import java.sql.PreparedStatement;

          import javax.naming.InitialContext;

          import org.jboss.resource.adapter.jdbc.WrappedConnection;

          import oracle.jdbc.OracleConnection;

           

          InitialContext ctx = new InitialContext();

          String sDataSource = "YOUR DATA SOURCE NAME HERE";

          Connection conn = ((DataSource)ctx.lookup(sDataSource)).getConnection();

           

          org.jboss.resource.adapter.jdbc.WrappedConnection oWConn = (WrappedConnection) conn;

          OracleConnection oConn = oWConn.getUnderlyingConnection();

           

          From that point forward, you can simply leverage the PreparedStatement and/or Statement classes for any statements.

           

          Please do let me know if you have any questions.

           

          Josh Boyle

          jboyle@cardinalsolutions.com

          Cardinal Solutions Group