PoolingDataSource (Bitronix Transaction Manager :: Core 2.1.4 API)
Date: 2013-09-15

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

## bitronix.tm.resource.jdbc
Class PoolingDataSource

    java.lang.Object
      bitronix.tm.resource.common.ResourceBean
          bitronix.tm.resource.jdbc.PoolingDataSource

All Implemented Interfaces:
  XAResourceProducer, PoolingDataSourceMBean, Serializable, Wrapper, Referenceable, CommonDataSource, DataSource

    public class PoolingDataSource

extends ResourceBean
implements DataSource, XAResourceProducer, PoolingDataSourceMBean

Implementation of a JDBC `DataSource` wrapping vendor's `XADataSource` implementation.

Author:
  lorban, brettw
See Also:
  Serialized Form

Constructor Summary
`PoolingDataSource()`

Method Summary
`void` | `addConnectionCustomizer(ConnectionCustomizer connectionCustomizer)`
`void` | `close()` Release this `XAResourceProducer`'s internal resources.
`XAStatefulHolder` | `createPooledConnection(Object xaFactory, ResourceBean bean)` Create a `XAStatefulHolder` that will be placed in an `XAPool`.
`void` | `endRecovery()` Release internal resources held after call to `startRecovery()`.
`XAResourceHolder` | `findXAResourceHolder(XAResource xaResource)` Find in the `XAResourceHolder`s created by this `XAResourceProducer` the one which this `XAResource` belongs to.
`Connection` | `getConnection()`
`Connection` | `getConnection(String username, String password)`
`String` | `getCursorHoldability()`
`long` | `getInPoolSize()`
`String` | `getIsolationLevel()`
`String` | `getLocalAutoCommit()`
`int` | `getLoginTimeout()`
`PrintWriter` | `getLogWriter()`
`int` | `getPreparedStatementCacheSize()`
`Reference` | `getReference()` `PoolingDataSource` must alway have a unique name so this method builds a reference to this object using the unique name as `RefAddr`.
`String` | `getTestQuery()`
`long` | `getTotalPoolSize()`
`void` | `init()` Initializes the pool by creating the initial amount of connections.
`boolean` | `isEnableJdbc4ConnectionTest()`
`boolean` | `isFailed()`
`boolean` | `isWrapperFor(Class<?> iface)`
`void` | `removeConnectionCustomizer(ConnectionCustomizer connectionCustomizer)`
`void` | `reset()`
`void` | `setCursorHoldability(String cursorHoldability)` Set the default cursor holdability for connections.
`void` | `setEnableJdbc4ConnectionTest(boolean enableJdbc4ConnectionTest)` When set and the underlying JDBC driver supports JDBC 4 isValid(), a Connection.isValid() call is performed to test the connection before handing it to the caller.
`void` | `setFailed(boolean failed)` Mark this resource producer as failed or not.
`void` | `setIsolationLevel(String isolationLevel)` Set the default isolation level for connections.
`void` | `setLocalAutoCommit(String localAutoCommit)` Set the default local transactions autocommit mode.
`void` | `setLoginTimeout(int seconds)`
`void` | `setLogWriter(PrintWriter out)`
`void` | `setPreparedStatementCacheSize(int preparedStatementCacheSize)` Set the target maximum size of the prepared statement cache.
`void` | `setTestQuery(String testQuery)` When set, the specified query will be executed on the connection acquired from the pool before being handed to the caller.
`XAResourceHolderState` | `startRecovery()` Prepare the recoverable `XAResource` producer for recovery.
`String` | `toString()`
`
`<T> T`
` | `unwrap(Class<T> iface)`

Methods inherited from class bitronix.tm.resource.common.ResourceBean
`getAcquireIncrement, getAcquisitionInterval, getAcquisitionTimeout, getAllowLocalTransactions, getApplyTransactionTimeout, getAutomaticEnlistingEnabled, getClassName, getDeferConnectionRelease, getDriverProperties, getIgnoreRecoveryFailures, getMaxIdleTime, getMaxPoolSize, getMinPoolSize, getShareTransactionConnections, getTwoPcOrderingPosition, getUniqueName, getUseTmJoin, incCreatedResourcesCounter, isDisabled, setAcquireIncrement, setAcquisitionInterval, setAcquisitionTimeout, setAllowLocalTransactions, setApplyTransactionTimeout, setAutomaticEnlistingEnabled, setClassName, setDeferConnectionRelease, setDisabled, setDriverProperties, setIgnoreRecoveryFailures, setMaxIdleTime, setMaxPoolSize, setMinPoolSize, setShareTransactionConnections, setTwoPcOrderingPosition, setUniqueName, setUseTmJoin`

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

Methods inherited from interface bitronix.tm.resource.common.XAResourceProducer
`getUniqueName`

Methods inherited from interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
`getMaxPoolSize, getMinPoolSize, isDisabled, setDisabled`

Constructor Detail

### PoolingDataSource

    public PoolingDataSource()

Method Detail

### init

    public void init()

  Initializes the pool by creating the initial amount of connections.

  Specified by:
    `init` in interface `XAResourceProducer`

### getTestQuery

    public String getTestQuery()

  Returns:
    the query that will be used to test connections.

### setTestQuery

    public void setTestQuery(String testQuery)

  When set, the specified query will be executed on the connection acquired from the pool before being handed to the caller. The connections won't be tested when not set. Default value is null.

  Parameters:
    `testQuery` - the query that will be used to test connections.

### setEnableJdbc4ConnectionTest

    public void setEnableJdbc4ConnectionTest(boolean enableJdbc4ConnectionTest)

  When set and the underlying JDBC driver supports JDBC 4 isValid(), a Connection.isValid() call is performed to test the connection before handing it to the caller. If both testQuery and enableJdbc4ConnectionTest are set, enableJdbc4ConnectionTest takes precedence.

  Parameters:
    `enableJdbc4ConnectionTest` - true if JDBC 4 isValid() testing should be performed, false otherwise.

### isEnableJdbc4ConnectionTest

    public boolean isEnableJdbc4ConnectionTest()

  Returns:
    true if JDBC 4 isValid() testing should be performed, false otherwise.

### getPreparedStatementCacheSize

    public int getPreparedStatementCacheSize()

  Returns:
    the target maximum prepared statement cache size.

### setPreparedStatementCacheSize

    public void setPreparedStatementCacheSize(int preparedStatementCacheSize)

  Set the target maximum size of the prepared statement cache. In reality under certain unusual conditions the cache may temporarily drift higher in size.

  Parameters:
    `preparedStatementCacheSize` - the target maximum prepared statement cache size.

### getIsolationLevel

    public String getIsolationLevel()

  Returns:
    the default isolation level.

### setIsolationLevel

    public void setIsolationLevel(String isolationLevel)

  Set the default isolation level for connections.

  Parameters:
    `isolationLevel` - the default isolation level.

### getCursorHoldability

    public String getCursorHoldability()

  Returns:
    cursorHoldability the default cursor holdability.

### setCursorHoldability

    public void setCursorHoldability(String cursorHoldability)

  Set the default cursor holdability for connections.

  Parameters:
    `cursorHoldability` - the default cursor holdability.

### getLocalAutoCommit

    public String getLocalAutoCommit()

  Returns:
    localAutoCommit the default local transactions autocommit mode.

### setLocalAutoCommit

    public void setLocalAutoCommit(String localAutoCommit)

  Set the default local transactions autocommit mode.

  Parameters:
    `localAutoCommit` - the default local transactions autocommit mode.

### addConnectionCustomizer

    public void addConnectionCustomizer(ConnectionCustomizer connectionCustomizer)

### removeConnectionCustomizer

    public void removeConnectionCustomizer(ConnectionCustomizer connectionCustomizer)

### getConnection

    public Connection getConnection()
                             throws SQLException

  Specified by:
    `getConnection` in interface `DataSource`
  Throws:
    `SQLException`

### getConnection

    public Connection getConnection(String username,
                                    String password)
                             throws SQLException

  Specified by:
    `getConnection` in interface `DataSource`
  Throws:
    `SQLException`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### startRecovery

    public XAResourceHolderState startRecovery()
                                        throws RecoveryException

  Description copied from interface: `XAResourceProducer`
  Prepare the recoverable `XAResource` producer for recovery.

  Specified by:
    `startRecovery` in interface `XAResourceProducer`
  Returns:
    a `XAResourceHolderState` object that can be used to call `recover()`.
  Throws:
    `RecoveryException` - thrown when a `XAResourceHolderState` cannot be acquired.

### endRecovery

    public void endRecovery()
                     throws RecoveryException

  Description copied from interface: `XAResourceProducer`
  Release internal resources held after call to `startRecovery()`.

  Specified by:
    `endRecovery` in interface `XAResourceProducer`
  Throws:
    `RecoveryException` - thrown when an error occured while releasing reserved resources.

### setFailed

    public void setFailed(boolean failed)

  Description copied from interface: `XAResourceProducer`
  Mark this resource producer as failed or not. A resource is considered failed if recovery fails to run on it.

  Specified by:
    `setFailed` in interface `XAResourceProducer`
  Parameters:
    `failed` - true is the resource must be considered failed, false it it must be considered sane.

### isFailed

    public boolean isFailed()

  Specified by:
    `isFailed` in interface `PoolingDataSourceMBean`

### close

    public void close()

  Description copied from interface: `XAResourceProducer`
  Release this `XAResourceProducer`'s internal resources.

  Specified by:
    `close` in interface `XAResourceProducer`

### createPooledConnection

    public XAStatefulHolder createPooledConnection(Object xaFactory,
                                                   ResourceBean bean)
                                            throws Exception

  Description copied from interface: `XAResourceProducer`
  Create a `XAStatefulHolder` that will be placed in an `XAPool`.

  Specified by:
    `createPooledConnection` in interface `XAResourceProducer`
  Parameters:
    `xaFactory` - the vendor's resource-specific XA factory.
    `bean` - the resource-specific bean describing the resource parameters.
  Returns:
    a `XAStatefulHolder` that will be placed in an `XAPool`.
  Throws:
    `Exception` - thrown when the `XAStatefulHolder` cannot be created.

### findXAResourceHolder

    public XAResourceHolder findXAResourceHolder(XAResource xaResource)

  Description copied from interface: `XAResourceProducer`
  Find in the `XAResourceHolder`s created by this `XAResourceProducer` the one which this `XAResource` belongs to.

  Specified by:
    `findXAResourceHolder` in interface `XAResourceProducer`
  Parameters:
    `xaResource` - the `XAResource` to look for.
  Returns:
    the associated `XAResourceHolder` or null if the `XAResource` does not belong to this `XAResourceProducer`.

### getReference

    public Reference getReference()
                           throws NamingException

  `PoolingDataSource` must alway have a unique name so this method builds a reference to this object using the unique name as `RefAddr`.

  Specified by:
    `getReference` in interface `Referenceable`
  Returns:
    a reference to this `PoolingDataSource`.
  Throws:
    `NamingException`

### getLoginTimeout

    public int getLoginTimeout()
                        throws SQLException

  Specified by:
    `getLoginTimeout` in interface `CommonDataSource`
  Throws:
    `SQLException`

### setLoginTimeout

    public void setLoginTimeout(int seconds)
                         throws SQLException

  Specified by:
    `setLoginTimeout` in interface `CommonDataSource`
  Throws:
    `SQLException`

### getLogWriter

    public PrintWriter getLogWriter()
                             throws SQLException

  Specified by:
    `getLogWriter` in interface `CommonDataSource`
  Throws:
    `SQLException`

### setLogWriter

    public void setLogWriter(PrintWriter out)
                      throws SQLException

  Specified by:
    `setLogWriter` in interface `CommonDataSource`
  Throws:
    `SQLException`

### isWrapperFor

    public boolean isWrapperFor(Class<?> iface)
                         throws SQLException

  Specified by:
    `isWrapperFor` in interface `Wrapper`
  Throws:
    `SQLException`

### unwrap

    public <T> T unwrap(Class<T> iface)
             throws SQLException

  Specified by:
    `unwrap` in interface `Wrapper`
  Throws:
    `SQLException`

### getInPoolSize

    public long getInPoolSize()

  Specified by:
    `getInPoolSize` in interface `PoolingDataSourceMBean`

### getTotalPoolSize

    public long getTotalPoolSize()

  Specified by:
    `getTotalPoolSize` in interface `PoolingDataSourceMBean`

### reset

    public void reset()
               throws Exception

  Specified by:
    `reset` in interface `PoolingDataSourceMBean`
  Throws:
    `Exception`

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 © 2006-2013 Bitronix Software. All Rights Reserved.