public class PGPooledConnection
extends java.lang.Object
implements javax.sql.PooledConnection
PGConnectionPoolDataSource| Modifier and Type | Class and Description |
|---|---|
private class |
PGPooledConnection.ConnectionHandler
Instead of declaring a class implementing Connection, which would have to be updated for every
JDK rev, use a dynamic proxy to handle all calls through the Connection interface.
|
private class |
PGPooledConnection.StatementHandler
Instead of declaring classes implementing Statement, PreparedStatement, and CallableStatement,
which would have to be updated for every JDK rev, use a dynamic proxy to handle all calls
through the Statement interfaces.
|
| Modifier and Type | Field and Description |
|---|---|
private boolean |
autoCommit |
private java.sql.Connection |
con |
private static java.lang.String[] |
fatalClasses |
private boolean |
isXA |
private PGPooledConnection.ConnectionHandler |
last |
private java.util.List<javax.sql.ConnectionEventListener> |
listeners |
| Constructor and Description |
|---|
PGPooledConnection(java.sql.Connection con,
boolean autoCommit) |
PGPooledConnection(java.sql.Connection con,
boolean autoCommit,
boolean isXA)
Creates a new PooledConnection representing the specified physical connection.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addConnectionEventListener(javax.sql.ConnectionEventListener connectionEventListener)
Adds a listener for close or fatal error events on the connection handed out to a client.
|
void |
addStatementEventListener(javax.sql.StatementEventListener listener) |
void |
close()
Closes the physical database connection represented by this PooledConnection.
|
protected javax.sql.ConnectionEvent |
createConnectionEvent(java.sql.SQLException e) |
(package private) void |
fireConnectionClosed()
Used to fire a connection closed event to all listeners.
|
private void |
fireConnectionError(java.sql.SQLException e)
Fires a connection error event, but only if we think the exception is fatal.
|
(package private) void |
fireConnectionFatalError(java.sql.SQLException e)
Used to fire a connection error event to all listeners.
|
java.sql.Connection |
getConnection()
Gets a handle for a client to use.
|
private static boolean |
isFatalState(java.lang.String state) |
void |
removeConnectionEventListener(javax.sql.ConnectionEventListener connectionEventListener)
Removes a listener for close or fatal error events on the connection handed out to a client.
|
void |
removeStatementEventListener(javax.sql.StatementEventListener listener) |
private final java.util.List<javax.sql.ConnectionEventListener> listeners
private java.sql.Connection con
private PGPooledConnection.ConnectionHandler last
private final boolean autoCommit
private final boolean isXA
private static java.lang.String[] fatalClasses
public PGPooledConnection(java.sql.Connection con,
boolean autoCommit,
boolean isXA)
con - connectionautoCommit - whether to autocommitisXA - whether connection is a XA connectionpublic PGPooledConnection(java.sql.Connection con,
boolean autoCommit)
public void addConnectionEventListener(javax.sql.ConnectionEventListener connectionEventListener)
addConnectionEventListener in interface javax.sql.PooledConnectionpublic void removeConnectionEventListener(javax.sql.ConnectionEventListener connectionEventListener)
removeConnectionEventListener in interface javax.sql.PooledConnectionpublic void close()
throws java.sql.SQLException
close in interface javax.sql.PooledConnectionjava.sql.SQLExceptionpublic java.sql.Connection getConnection()
throws java.sql.SQLException
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.
getConnection in interface javax.sql.PooledConnectionjava.sql.SQLExceptionvoid fireConnectionClosed()
void fireConnectionFatalError(java.sql.SQLException e)
protected javax.sql.ConnectionEvent createConnectionEvent(java.sql.SQLException e)
private static boolean isFatalState(java.lang.String state)
private void fireConnectionError(java.sql.SQLException e)
e - the SQLException to considerpublic void removeStatementEventListener(javax.sql.StatementEventListener listener)
removeStatementEventListener in interface javax.sql.PooledConnectionpublic void addStatementEventListener(javax.sql.StatementEventListener listener)
addStatementEventListener in interface javax.sql.PooledConnection