com.jnetdirect.jsql
Class JSQLXADataSource

java.lang.Object
  extended by com.jnetdirect.datasource.BaseDatasource
      extended by com.jnetdirect.jsql.JSQLDataSource
          extended by com.jnetdirect.jsql.JSQLConnectionPoolDataSource
              extended by com.jnetdirect.jsql.JSQLXADataSource
All Implemented Interfaces:
java.io.Serializable, java.sql.Wrapper, javax.naming.Referenceable, javax.sql.CommonDataSource, javax.sql.ConnectionPoolDataSource, javax.sql.DataSource, javax.sql.XADataSource

public class JSQLXADataSource
extends JSQLConnectionPoolDataSource
implements javax.sql.XADataSource

JSQLXADataSource provides database connections for use in distributed (XA) transactions. JSQLXADataSource also supports connection pooling of physical connections. The XADataSource and XAConnection interfaces, which are defined in the package javax.sql, are implemented by JSQLConnect. An XAConnection object is a pooled connection that can participate in a distributed transaction. More precisely, XAConnection extends the PooledConnection interface by adding the method getXAResource. This method produces an XAResource object that can be used by a transaction manager to coordinate the work done on this connection with the other participants in the distributed transaction.

  • Because they extend the PooledConnection interface, XAConnection objects support all the methods of PooledConnection objects. They are reusable physical connections to an underlying data source and produce logical connection handles that can be passed back to a JDBC application.
  • XAConnection objects are produced by an XADataSource object. There is some similarity between ConnectionPoolDataSource objects and XADataSource objects in that they are both implemented below a DataSource layer that is visible to the JDBC application. This architecture allows JSQLConnect to support distributed transactions in a way that is transparent to the application.

    JSQLXADataSource can be configured to integrate with Microsoft Distributed Transaction Coordinator (DTC) to provide true, distributed transaction processing. Integration with DTC is enabled using the setDtcEnabled() method or the 'dtcEnabled' datasource property. By default the datasource uses local transactions to handle transaction processing.

    See Also:
    Serialized Form

    Field Summary
     
    Fields inherited from class com.jnetdirect.datasource.BaseDatasource
    debugLog
     
    Constructor Summary
    JSQLXADataSource()
               
     
    Method Summary
     java.lang.String getDtcEnabled()
              Get the MS DTC setting
     java.lang.String getDtcLoggingEnabled()
              Get the MS DTC logging setting
     javax.sql.XAConnection getXAConnection()
              Obtain a physical database connection to particate in an XA transaction.
     javax.sql.XAConnection getXAConnection(java.lang.String user, java.lang.String password)
              Obtain a physical database connection to particate in an XA transaction with the specified user and password.
     boolean isWrapperFor(java.lang.Class iface)
               
     void setDtcEnabled(java.lang.String way)
              Set DTC Enabled
     void setDtcLoggingEnabled(java.lang.String way)
              Controls logging of MS Distributed Transaction Coordinator (MS-DTC) calls.
     java.lang.Object unwrap(java.lang.Class iface)
               
     
    Methods inherited from class com.jnetdirect.jsql.JSQLConnectionPoolDataSource
    getPooledConnection, getPooledConnection
     
    Methods inherited from class com.jnetdirect.jsql.JSQLDataSource
    getApplicationName, getAsciiStringParameters, getBooleanLiterals, getCodepage, getConnection, getConnection, getConnectionRetryCount, getConnectionRetryWait, getDisableStatementPooling, getDomain, getEnableFailover, getInstanceName, getIterativeBatching, getLastUpdateCount, getLockTimeout, getNetLibType, getPacketSize, getPreExecuteMetaData, getSelectMethod, getSqlVersion, getSsl, getSslTrusted, getTrustedAuthentication, getTrustedAuthenticationPort, getXopenStates, setApplicationName, setAsciiStringParameters, setBooleanLiterals, setCodepage, setConnectionRetryCount, setConnectionRetryWait, setDisableStatementPooling, setDomain, setEnableFailover, setInstanceName, setIterativeBatching, setLastUpdateCount, setLockTimeout, setNetLibType, setPacketSize, setPreExecuteMetaData, setSelectMethod, setSqlVersion, setSsl, setSslTrusted, setTrustedAuthentication, setTrustedAuthenticationPort, setXopenStates
     
    Methods inherited from class com.jnetdirect.datasource.BaseDatasource
    getConnectionVerifyTable, getDatabase, getDatabaseName, getDescription, getInitialPoolSize, getLogfile, getLoginTimeout, getLogWriter, getManagementCycleTime, getMaxConnectionBacklog, getMaxIdleTime, getMaxPoolSize, getMinPoolSize, getPassword, getPortNumber, getProperties, getPropertyCycle, getReference, getServerName, getUrl, getURL, getUser, setConnectionVerifyTable, setDatabase, setDatabaseName, setDescription, setInitialPoolSize, setLogfile, setLoginTimeout, setLogWriter, setManagementCycleTime, setMaxConnectionBacklog, setMaxIdleTime, setMaxPoolSize, setMinPoolSize, setPassword, setPortNumber, setProperties, setProperty, setPropertyCycle, setServerName, setUrl, setURL, setUser
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     
    Methods inherited from interface javax.sql.CommonDataSource
    getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
     

    Constructor Detail

    JSQLXADataSource

    public JSQLXADataSource()
    Method Detail

    getXAConnection

    public javax.sql.XAConnection getXAConnection(java.lang.String user,
                                                  java.lang.String password)
                                           throws java.sql.SQLException
    Obtain a physical database connection to particate in an XA transaction with the specified user and password. This API should only be called by XA connection pool implementations, not regular JDBC application code.

    Specified by:
    getXAConnection in interface javax.sql.XADataSource
    Returns:
    A new XAConnection
    Throws:
    java.sql.SQLException - The database connection failed.

    getXAConnection

    public javax.sql.XAConnection getXAConnection()
                                           throws java.sql.SQLException
    Obtain a physical database connection to particate in an XA transaction. This API should only be called by XA connection pool implementations, not regular JDBC application code.

    Specified by:
    getXAConnection in interface javax.sql.XADataSource
    Returns:
    A new XAConnection
    Throws:
    java.sql.SQLException - The database connection failed.

    setDtcEnabled

    public void setDtcEnabled(java.lang.String way)
    Set DTC Enabled

    Parameters:
    "false" - or "0" - MS DTC is not used. This is the default. XA transactions are implemented by local transactions.
    "true" - or "1" - MS DTC is used to support XA distributed transactions

    getDtcEnabled

    public java.lang.String getDtcEnabled()
    Get the MS DTC setting

    Returns:
    "true" if MS DTC is specified to be used for distributed transactions

    setDtcLoggingEnabled

    public void setDtcLoggingEnabled(java.lang.String way)
    Controls logging of MS Distributed Transaction Coordinator (MS-DTC) calls. Logging is generated to WINNT\system32\JSQL_XA_TRACE.txt.

    Parameters:
    way - "false" or "0" - MS DTC logging is disabled. Only errors are logged to the log file.
    way - "true" or "1" - MS DTC logging is enabled. Both errors and API calls are logged to the log file.

    getDtcLoggingEnabled

    public java.lang.String getDtcLoggingEnabled()
    Get the MS DTC logging setting

    Returns:
    TRUE if MS DTC logging is enabled.

    isWrapperFor

    public boolean isWrapperFor(java.lang.Class iface)
                         throws java.sql.SQLException
    Specified by:
    isWrapperFor in interface java.sql.Wrapper
    Overrides:
    isWrapperFor in class JSQLConnectionPoolDataSource
    Throws:
    java.sql.SQLException

    unwrap

    public java.lang.Object unwrap(java.lang.Class iface)
                            throws java.sql.SQLException
    Specified by:
    unwrap in interface java.sql.Wrapper
    Overrides:
    unwrap in class JSQLConnectionPoolDataSource
    Throws:
    java.sql.SQLException