Use JTA/JDBC coordination

Code your API calls as in the supplied example.

The basic sequence of API calls for a user application is:
  qMgr = new MQQueueManager("QM1")
  Connection con = qMgr.getJDBCConnection( xads );
  qMgr.begin()

 < Perform MQ and DB operations to be grouped in a unit of work >

  qMgr.commit() or qMgr.backout();
  con.close()
  qMgr.disconnect()
xads in the getJDBCConnection call is a database-specific implementation of the XADataSource interface, which defines the details of the database to connect to. See the documentation for your database to determine how to create an appropriate XADataSource object to pass into getJDBCConnection.

You must also update your class path with the appropriate database-specific jar files for performing JDBC work.

If you must connect to multiple databases, you must call getJDBCConnection several times to perform the transaction across several different connections.

There are two forms of the getJDBCConnection, reflecting the two forms of XADataSource.getXAConnection:
  public java.sql.Connection getJDBCConnection(javax.sql.XADataSource xads)
    throws MQException, SQLException, Exception

  public java.sql.Connection getJDBCConnection(XADataSource dataSource,
                                            String userid, String password)
    throws MQException, SQLException, Exception
These methods declare Exception in their throws clauses to avoid problems with the JVM verifier for customers who are not using the JTA functions. The actual exception thrown is javax.transaction.xa.XAException which requires the jta.jar file to be added to the class path for programs that did not previously require it. To use the JTA/JDBC support, you must include the following statement in our application:
MQEnvironment.properties.put(CMQC.THREAD_AFFINITY_PROPERTY, new Boolean(true));