org.apache.tomcat.dbcp.dbcp

## Class PoolingDataSource<C extends java.sql.Connection>

- java.lang.Object
- - org.apache.tomcat.dbcp.dbcp.PoolingDataSource<C>

- All Implemented Interfaces:
    java.sql.Wrapper, javax.sql.CommonDataSource, javax.sql.DataSource

      public class PoolingDataSource<C extends java.sql.Connection>
      extends java.lang.Object
      implements javax.sql.DataSource

  A simple `DataSource` implementation that obtains `Connection`s from the specified `ObjectPool`.
  Author:
    Rodney Waldhoff, Glenn L. Nielsen, James House, Dirk Verbeeck

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.io.PrintWriter` | `_logWriter` My log writer.
    `protected ObjectPool<C>` | `_pool`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PoolingDataSource()`
    `PoolingDataSource(ObjectPool<C> pool)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.sql.Connection` | `getConnection()` Return a `Connection` from my pool, according to the contract specified by `ObjectPool.borrowObject()`.
    `java.sql.Connection` | `getConnection(java.lang.String uname, java.lang.String passwd)` Throws `UnsupportedOperationException`
    `int` | `getLoginTimeout()` Throws `UnsupportedOperationException`.
    `java.io.PrintWriter` | `getLogWriter()` Returns my log writer.
    `java.util.logging.Logger` | `getParentLogger()`
    `boolean` | `isAccessToUnderlyingConnectionAllowed()` Returns the value of the accessToUnderlyingConnectionAllowed property.
    `boolean` | `isWrapperFor(java.lang.Class<?> iface)`
    `void` | `setAccessToUnderlyingConnectionAllowed(boolean allow)` Sets the value of the accessToUnderlyingConnectionAllowed property.
    `void` | `setLoginTimeout(int seconds)` Throws `UnsupportedOperationException`.
    `void` | `setLogWriter(java.io.PrintWriter out)` Sets my log writer.
    `void` | `setPool(ObjectPool<C> pool)`
    `<T> T` | `unwrap(java.lang.Class<T> iface)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _logWriter

          protected java.io.PrintWriter _logWriter

      My log writer.

    - #### _pool

          protected ObjectPool<C extends java.sql.Connection> _pool

  - ### Constructor Detail

    - #### PoolingDataSource

          public PoolingDataSource()

    - #### PoolingDataSource

          public PoolingDataSource(ObjectPool<C> pool)

  - ### Method Detail

    - #### setPool

          public void setPool(ObjectPool<C> pool)
                       throws java.lang.IllegalStateException,
                              java.lang.NullPointerException

      Throws:
        `java.lang.IllegalStateException`
        `java.lang.NullPointerException`

    - #### isAccessToUnderlyingConnectionAllowed

          public boolean isAccessToUnderlyingConnectionAllowed()

      Returns the value of the accessToUnderlyingConnectionAllowed property.
      Returns:
        true if access to the underlying is allowed, false otherwise.

    - #### setAccessToUnderlyingConnectionAllowed

          public void setAccessToUnderlyingConnectionAllowed(boolean allow)

      Sets the value of the accessToUnderlyingConnectionAllowed property. It controls if the PoolGuard allows access to the underlying connection. (Default: false)
      Parameters:
        `allow` - Access to the underlying connection is granted when true.

    - #### isWrapperFor

          public boolean isWrapperFor(java.lang.Class<?> iface)
                               throws java.sql.SQLException

      Specified by:
        `isWrapperFor` in interface `java.sql.Wrapper`
      Throws:
        `java.sql.SQLException`

    - #### unwrap

          public <T> T unwrap(java.lang.Class<T> iface)
                   throws java.sql.SQLException

      Specified by:
        `unwrap` in interface `java.sql.Wrapper`
      Throws:
        `java.sql.SQLException`

    - #### getParentLogger

          public java.util.logging.Logger getParentLogger()
                                                   throws java.sql.SQLFeatureNotSupportedException

      Specified by:
        `getParentLogger` in interface `javax.sql.CommonDataSource`
      Throws:
        `java.sql.SQLFeatureNotSupportedException`

    - #### getConnection

          public java.sql.Connection getConnection()
                                            throws java.sql.SQLException

      Return a `Connection` from my pool, according to the contract specified by `ObjectPool.borrowObject()`.
      Specified by:
        `getConnection` in interface `javax.sql.DataSource`
      Throws:
        `java.sql.SQLException`

    - #### getConnection

          public java.sql.Connection getConnection(java.lang.String uname,
                                          java.lang.String passwd)
                                            throws java.sql.SQLException

      Throws `UnsupportedOperationException`
      Specified by:
        `getConnection` in interface `javax.sql.DataSource`
      Throws:
        `java.lang.UnsupportedOperationException`
        `java.sql.SQLException`

    - #### getLogWriter

          public java.io.PrintWriter getLogWriter()

      Returns my log writer.
      Specified by:
        `getLogWriter` in interface `javax.sql.CommonDataSource`
      Returns:
        my log writer
      See Also:
        `CommonDataSource.getLogWriter()`

    - #### getLoginTimeout

          public int getLoginTimeout()

      Throws `UnsupportedOperationException`.
      Specified by:
        `getLoginTimeout` in interface `javax.sql.CommonDataSource`
      Throws:
        `java.lang.UnsupportedOperationException` - As this implementation does not support this feature.

    - #### setLoginTimeout

          public void setLoginTimeout(int seconds)

      Throws `UnsupportedOperationException`.
      Specified by:
        `setLoginTimeout` in interface `javax.sql.CommonDataSource`
      Throws:
        `java.lang.UnsupportedOperationException` - As this implementation does not support this feature.

    - #### setLogWriter

          public void setLogWriter(java.io.PrintWriter out)

      Sets my log writer.
      Specified by:
        `setLogWriter` in interface `javax.sql.CommonDataSource`
      See Also:
        `CommonDataSource.setLogWriter(java.io.PrintWriter)`

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.