com.pivotal.gemfirexd.internal.client

## Class ClientPooledConnection

- java.lang.Object
- - com.pivotal.gemfirexd.internal.client.ClientPooledConnection

All Implemented Interfaces:
  PooledConnection

Direct Known Subclasses:
  ClientPooledConnection40, ClientXAConnection

    public abstract class ClientPooledConnection
    extends Object
    implements PooledConnection

A physical connection to a data source, to be used for creating logical connections to the same data source.

### Field Summary

Fields
`protected LogWriter` `logWriter_`
`protected int` `rmId_` Resource manager identificator.

### Constructor Summary

Constructors
Constructor and Description
`ClientPooledConnection(ClientBaseDataSource ds, LogWriter logWriter, String user, String password)` Constructor for non-XA pooled connections.
`ClientPooledConnection(ClientBaseDataSource ds, LogWriter logWriter, String user, String password, int rmId)` Constructor for XA pooled connections only.

### Method Summary

Methods
`void` `addConnectionEventListener(ConnectionEventListener listener)`
`void` `close()` Closes the physical connection to the data source and frees all assoicated resources.
`protected void` `finalize()`
`Connection` `getConnection()` Creates a logical connection.
`protected NetXAConnection` `getNetXAConnection(ClientBaseDataSource ds, NetLogWriter logWriter, String user, String password, int rmId)` creates and returns NetXAConnection.
`void` `informListeners(SqlException exception)` Inform listeners that an error has occured on the connection, if the error severity is high enough.
`boolean` `isStatementPoolingEnabled()` Tells is statement pooling is enabled or not.
`void` `nullLogicalConnection()` Used by `LogicalConnection.close` in some circumstances when it disassociates itself from the pooled connection.
`void` `onStatementClose(PreparedStatement statement)` The onStatementClose contains the logic for raising the Statement Closed events.
`void` `onStatementErrorOccurred(PreparedStatement statement, SQLException sqle)` The method contains the logic for raising the Statement error occurred events.
`void` `recycleConnection()` Inform listeners that the logical connection has been closed and that the physical connection is ready for reuse.
`void` `removeConnectionEventListener(ConnectionEventListener listener)`

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

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

### Methods inherited from interface javax.sql.PooledConnection

`addStatementEventListener, removeStatementEventListener`

### Field Detail

#### logWriter_

    protected LogWriter logWriter_

#### rmId_

    protected int rmId_

Resource manager identificator.

### Constructor Detail

#### ClientPooledConnection

    public ClientPooledConnection(ClientBaseDataSource ds,
                          LogWriter logWriter,
                          String user,
                          String password)
                           throws SQLException

Constructor for non-XA pooled connections.

Using standard Java APIs, a CPDS is passed in. Arguments for user/password overrides anything on the data source.

Parameters:
  `ds` - data source creating this pooled connection
  `logWriter` - destination for log messages
  `user` - user name
  `password` - user password
Throws:
  `SQLException` - if creating the pooled connection fails due problems in the database, or problems communicating with the database

#### ClientPooledConnection

    public ClientPooledConnection(ClientBaseDataSource ds,
                          LogWriter logWriter,
                          String user,
                          String password,
                          int rmId)
                           throws SQLException

Constructor for XA pooled connections only.

Using standard Java APIs, a CPDS is passed in. Arguments for user/password overrides anything on the data source.

Parameters:
  `ds` - data source creating this pooled connection
  `logWriter` - destination for log messages
  `user` - user name
  `password` - user password
  `rmId` - resource manager id
Throws:
  `SQLException` - if creating the pooled connection fails due problems in the database, or problems communicating with the database

### Method Detail

#### isStatementPoolingEnabled

    public boolean isStatementPoolingEnabled()

Tells is statement pooling is enabled or not.

Returns:
  `true` if enabled, `false` if disabled.

#### finalize

    protected void finalize()
                     throws Throwable

Overrides:
  `finalize` in class `Object`
Throws:
  `Throwable`

#### close

    public void close()
               throws SQLException

Closes the physical connection to the data source and frees all assoicated resources.

Specified by:
  `close` in interface `PooledConnection`
Throws:
  `SQLException` - if closing the connection causes an error. Note that this connection can still be considered closed even if an error occurs.

#### getConnection

    public Connection getConnection()
                             throws SQLException

Creates a logical connection.

This is the standard API for getting a logical connection handle for a pooled connection. No "resettable" properties are passed, so user, password, and all other properties may not change.

Specified by:
  `getConnection` in interface `PooledConnection`
Throws:
  `SQLException` - if creating a new logical connection fails

#### addConnectionEventListener

    public void addConnectionEventListener(ConnectionEventListener listener)

Specified by:
  `addConnectionEventListener` in interface `PooledConnection`

#### removeConnectionEventListener

    public void removeConnectionEventListener(ConnectionEventListener listener)

Specified by:
  `removeConnectionEventListener` in interface `PooledConnection`

#### recycleConnection

    public void recycleConnection()

Inform listeners that the logical connection has been closed and that the physical connection is ready for reuse.

Not public, but needs to be visible to am.LogicalConnection

#### informListeners

    public void informListeners(SqlException exception)

Inform listeners that an error has occured on the connection, if the error severity is high enough.

Not public, but needs to be visible to am.LogicalConnection

Parameters:
  `exception` - the exception that occurred on the connection

#### nullLogicalConnection

    public void nullLogicalConnection()

Used by `LogicalConnection.close` in some circumstances when it disassociates itself from the pooled connection.

#### onStatementClose

    public void onStatementClose(PreparedStatement statement)

The onStatementClose contains the logic for raising the Statement Closed events. This method has a dummy implementation here to avoid error when this class is compiled with jdk1.4. The class the actual implementation in ClientPooledConnection40.

Parameters:
  `statement` - The PreparedStatement that was closed

#### onStatementErrorOccurred

    public void onStatementErrorOccurred(PreparedStatement statement,
                                SQLException sqle)

The method contains the logic for raising the Statement error occurred events. This method has a dummy implementation here to avoid error when this class is compiled with jdk1.4. The class the actual implementation in ClientPooledConnection40.

Parameters:
  `statement` - The PreparedStatement that was closed
  `sqle` - The SQLException associated with the error that caused the invalidation of this PreparedStatement

#### getNetXAConnection

    protected NetXAConnection getNetXAConnection(ClientBaseDataSource ds,
                                     NetLogWriter logWriter,
                                     String user,
                                     String password,
                                     int rmId)
                                          throws SqlException

creates and returns NetXAConnection. Overwrite this method to create different version of NetXAConnection

Parameters:
  `ds` -
  `logWriter` -
  `user` -
  `password` -
  `rmId` -
Returns:
  NetXAConnection
Throws:
  `SqlException`