Package com.impossibl.postgres.jdbc
Class PGPooledConnection
- java.lang.Object
-
- com.impossibl.postgres.jdbc.PGPooledConnection
-
- All Implemented Interfaces:
PooledConnection
- Direct Known Subclasses:
PGXAConnection
public class PGPooledConnection extends Object implements PooledConnection
PooledConnection implementation
-
-
Constructor Summary
Constructors Constructor Description PGPooledConnection(PGDirectConnection con, boolean autoCommit, boolean isXA)
Creates a new PooledConnection representing the specified physical connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConnectionEventListener(ConnectionEventListener connectionEventListener)
void
addStatementEventListener(StatementEventListener statementEventListener)
void
close()
Closes the physical database connection represented by this PooledConnection.protected ConnectionEvent
createConnectionEvent(SQLException sqle)
protected StatementEvent
createStatementEvent(PreparedStatement ps, SQLException sqle)
void
fireConnectionError(SQLException e)
Fires a connection error event, but only if we think the exception is fatal.Connection
getConnection()
protected PGPooledConnectionDelegator
getConnectionHandle()
Gets a handle for a client to use.void
removeConnectionEventListener(ConnectionEventListener connectionEventListener)
void
removeStatementEventListener(StatementEventListener statementEventListener)
-
-
-
Constructor Detail
-
PGPooledConnection
public PGPooledConnection(PGDirectConnection con, boolean autoCommit, boolean isXA)
Creates a new PooledConnection representing the specified physical connection.
-
-
Method Detail
-
addConnectionEventListener
public void addConnectionEventListener(ConnectionEventListener connectionEventListener)
- Specified by:
addConnectionEventListener
in interfacePooledConnection
-
removeConnectionEventListener
public void removeConnectionEventListener(ConnectionEventListener connectionEventListener)
- Specified by:
removeConnectionEventListener
in interfacePooledConnection
-
addStatementEventListener
public void addStatementEventListener(StatementEventListener statementEventListener)
- Specified by:
addStatementEventListener
in interfacePooledConnection
-
removeStatementEventListener
public void removeStatementEventListener(StatementEventListener statementEventListener)
- Specified by:
removeStatementEventListener
in interfacePooledConnection
-
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 interfacePooledConnection
- Throws:
SQLException
-
getConnectionHandle
protected PGPooledConnectionDelegator getConnectionHandle() 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 pgysical 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.
- Throws:
SQLException
-
getConnection
public Connection getConnection() throws SQLException
- Specified by:
getConnection
in interfacePooledConnection
- Throws:
SQLException
-
createConnectionEvent
protected ConnectionEvent createConnectionEvent(SQLException sqle)
-
fireConnectionError
public void fireConnectionError(SQLException e)
Fires a connection error event, but only if we think the exception is fatal.- Parameters:
e
- the SQLException to consider
-
createStatementEvent
protected StatementEvent createStatementEvent(PreparedStatement ps, SQLException sqle)
-
-