Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.atomikos.jdbc
Class XAConnectionFactory

    java.lang.Object
      com.atomikos.jdbc.XAConnectionFactory

All Implemented Interfaces:
  ConnectionFactory

    public class XAConnectionFactory

extends Object
implements ConnectionFactory

A default connection factory for XA connections that work with the Atomikos connection pools.

Constructor Summary
`` | `XAConnectionFactory(String resourceName, String userName, String passwd, XADataSource xaDataSource)` Creates a new instance with a given resource name, user name and password for the XADataSource.
`protected` | `XAConnectionFactory(String resourceName, String userName, String passwd, XADataSource xaDataSource, JdbcTransactionalResource res)` Constructor for subclasses with their own transactional resource.
`` | `XAConnectionFactory(String resourceName, String userName, String passwd, XADataSource xaDataSource, XidFactory xidFactory)` Creates a new instance with a given resource name, user name and password for the XADataSource, and a custom XidFactory.

Method Summary
`int` | `getLoginTimeout()` Get the login timeout in seconds
`PrintWriter` | `getLogWriter()` Gets the log writer for debugging.
`protected String` | `getPassword()` Used by getPooledConnection() to get a connection.
`XPooledConnection` | `getPooledConnection()` The main method: gets a new DTPPooledConnection instance.
`TransactionalResource` | `getTransactionalResource()` Get the transactional resource.
`protected String` | `getUserName()` Used by getPooledConnection() to get a connection.
`XADataSource` | `getXADataSource()` This method gets the underlying data source.
`boolean` | `isExclusive()` Tests if the connections that are generated will be exclusive or not.
`void` | `setExclusive(boolean exclusive)` Sets the connections generated to exclusive for 2PC.
`void` | `setLoginTimeout(int secs)` Sets the login timeout.
`void` | `setLogWriter(PrintWriter pw)` Sets the log writer for debugging.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XAConnectionFactory

    protected XAConnectionFactory(String resourceName,
                                  String userName,
                                  String passwd,
                                  XADataSource xaDataSource,
                                  JdbcTransactionalResource res)

  Constructor for subclasses with their own transactional resource.

### XAConnectionFactory

    public XAConnectionFactory(String resourceName,
                               String userName,
                               String passwd,
                               XADataSource xaDataSource)

  Creates a new instance with a given resource name, user name and password for the XADataSource.

  Parameters:
    `resourceName` - The unique resource name for the corresponding JdbcTransactionalResource (which will be created automatically).
    `userName` - The user name to use for getting XA connections. Null if no authentication is supported by the supplied XADataSource.
    `passwd` - The password for the user, or null if no authentication is supported by the supplied XADataSource.
    `xaDataSource` - The XADataSource to use.

### XAConnectionFactory

    public XAConnectionFactory(String resourceName,
                               String userName,
                               String passwd,
                               XADataSource xaDataSource,
                               XidFactory xidFactory)

  Creates a new instance with a given resource name, user name and password for the XADataSource, and a custom XidFactory.

  Parameters:
    `resourceName` - The unique resource name for the corresponding JdbcTransactionalResource (which will be created automatically).
    `userName` - The user name to use for getting XA connections. Null if no authentication is supported by the supplied XADataSource.
    `passwd` - The password for the user, or null if no authentication is supported by the supplied XADataSource.
    `xaDataSource` - The XADataSource to use.
    `xidFactory` - The custom XidFactory.

Method Detail

### getUserName

    protected String getUserName()

  Used by getPooledConnection() to get a connection. If the drivers do not support authentication, then an empty string should be returned here.

  Returns:
    String The user name, or null if not applicable.

### getPassword

    protected String getPassword()

  Used by getPooledConnection() to get a connection.

  Returns:
    String The password, or null if not applicable.

### getXADataSource

    public XADataSource getXADataSource()

  This method gets the underlying data source. It is called by getPooledConnection() to get connections.

  Returns:
    XADataSource The data source to get XAConnections from.

### setExclusive

    public void setExclusive(boolean exclusive)

  Sets the connections generated to exclusive for 2PC. This mode is needed for certain databases that do not conform to XA entirely.

  Parameters:
    `exclusive` - If true, then connections will be kept until after commit/rollback, resulting in lower reuse.

### isExclusive

    public boolean isExclusive()

  Tests if the connections that are generated will be exclusive or not.

  Returns:
    boolean True iff connections are exclusive.

### getTransactionalResource

    public TransactionalResource getTransactionalResource()

  Get the transactional resource.

  Returns:
    TransactionalResource The transactional resource.

### getPooledConnection

    public XPooledConnection getPooledConnection()
                                          throws IllegalStateException,
                                                 SQLException

  The main method: gets a new DTPPooledConnection instance.

  Specified by:
    `getPooledConnection` in interface `ConnectionFactory`
  Returns:
    XPooledConnection An instance of DTPPooledConnection for use with DTPConnectionPool.
  Throws:
    `IllegalStateException` - If not initialized.
    `SQLException` - On sql errors.

### getLogWriter

    public PrintWriter getLogWriter()
                             throws SQLException

  Description copied from interface: `ConnectionFactory`
  Gets the log writer for debugging.

  Specified by:
    `getLogWriter` in interface `ConnectionFactory`
  Returns:
    PrintWriter The log writer; null if none or if not supported.
  Throws:
    `SQLException` - On error.

### setLogWriter

    public void setLogWriter(PrintWriter pw)
                      throws SQLException

  Description copied from interface: `ConnectionFactory`
  Sets the log writer for debugging.

  Specified by:
    `setLogWriter` in interface `ConnectionFactory`
  Parameters:
    `pw` - The print writer to log to.
  Throws:
    `SQLException` - On error.

### getLoginTimeout

    public int getLoginTimeout()
                        throws SQLException

  Description copied from interface: `ConnectionFactory`
  Get the login timeout in seconds

  Specified by:
    `getLoginTimeout` in interface `ConnectionFactory`
  Returns:
    int The no of secs before login times out.
  Throws:
    `SQLException` - On error.

### setLoginTimeout

    public void setLoginTimeout(int secs)
                         throws SQLException

  Description copied from interface: `ConnectionFactory`
  Sets the login timeout.

  Specified by:
    `setLoginTimeout` in interface `ConnectionFactory`
  Parameters:
    `secs` - The no of seconds.
  Throws:
    `SQLException` - On error.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012. All Rights Reserved.