nl.topicus.jdbc

## Class CloudSpannerPooledConnection

- java.lang.Object
- - nl.topicus.jdbc.CloudSpannerPooledConnection

All Implemented Interfaces:
  PooledConnection

    public class CloudSpannerPooledConnection
    extends Object
    implements PooledConnection

Implementation of the PooledConnection interface. This implementation is based on the implementation of PostgreSQL. PostgreSQL is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses. PostgreSQL Database Management System (formerly known as Postgres, then as Postgres95) Portions Copyright (c) 1996-2017, The PostgreSQL Global Development Group Portions Copyright (c) 1994, The Regents of the University of California IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

Author:
  loite

### Constructor Summary

Constructors
Constructor and Description
`CloudSpannerPooledConnection(Connection con, boolean autoCommit)`
`CloudSpannerPooledConnection(Connection con, boolean autoCommit, boolean isXA)` Creates a new PooledConnection representing the specified physical connection.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addConnectionEventListener(ConnectionEventListener connectionEventListener)` Adds a listener for close or fatal error events on the connection handed out to a client.
`void` `addStatementEventListener(StatementEventListener listener)`
`void` `close()` Closes the physical database connection represented by this PooledConnection.
`protected ConnectionEvent` `createConnectionEvent(SQLException e)`
`ICloudSpannerConnection` `getConnection()` Gets a handle for a client to use.
`Logger` `getParentLogger()`
`void` `removeConnectionEventListener(ConnectionEventListener connectionEventListener)` Removes a listener for close or fatal error events on the connection handed out to a client.
`void` `removeStatementEventListener(StatementEventListener listener)`

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

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

### Constructor Detail

#### CloudSpannerPooledConnection

    public CloudSpannerPooledConnection(Connection con,
                                        boolean autoCommit,
                                        boolean isXA)

Creates a new PooledConnection representing the specified physical connection.

Parameters:
  `con` - connection
  `autoCommit` - whether to autocommit
  `isXA` - whether connection is a XA connection

#### CloudSpannerPooledConnection

    public CloudSpannerPooledConnection(Connection con,
                                        boolean autoCommit)

### Method Detail

#### addConnectionEventListener

    public void addConnectionEventListener(ConnectionEventListener connectionEventListener)

Adds a listener for close or fatal error events on the connection handed out to a client.

Specified by:
  `addConnectionEventListener` in interface `PooledConnection`

#### removeConnectionEventListener

    public void removeConnectionEventListener(ConnectionEventListener connectionEventListener)

Removes a listener for close or fatal error events on the connection handed out to a client.

Specified by:
  `removeConnectionEventListener` in interface `PooledConnection`

#### close

    public void close()
               throws SQLException

Closes the physical database connection represented by this PooledConnection. If any client has a connection based on this PooledConnection, it is forcibly closed as well.

Specified by:
  `close` in interface `PooledConnection`
Throws:
  `SQLException`

#### getConnection

    public ICloudSpannerConnection getConnection()
                                          throws SQLException

Gets a handle for a client to use. This is a wrapper around the physical connection, so the client can call close and it will just return the connection to the pool without really closing the physical connection.

According to the JDBC 2.0 Optional Package spec (6.2.3), only one client may have an active handle to the connection at a time, so if there is a previous handle active when this is called, the previous one is forcibly closed and its work rolled back.

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

#### createConnectionEvent

    protected ConnectionEvent createConnectionEvent(SQLException e)

#### removeStatementEventListener

    public void removeStatementEventListener(StatementEventListener listener)

Specified by:
  `removeStatementEventListener` in interface `PooledConnection`

#### addStatementEventListener

    public void addStatementEventListener(StatementEventListener listener)

Specified by:
  `addStatementEventListener` in interface `PooledConnection`

#### getParentLogger

    public Logger getParentLogger()
                           throws SQLFeatureNotSupportedException

Throws:
  `SQLFeatureNotSupportedException`