|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.as400.access.AS400JDBCPooledConnection
public class AS400JDBCPooledConnection
The AS400JDBCPooledConnection class represents a connection object
that provides hooks for connection pool management. This object is returned
by the AS400JDBCConnectionPoolDataSource.getPooledConnection()
method.
The following example creates an AS400JDBCPooledConnection object that can be used to cache JDBC connections.
// Create a data source for making the connection. AS400JDBCConnectionPoolDataSource dataSource = new AS400JDBCConnectionPoolDataSource("myAS400"); datasource.setUser("Mickey Mouse"); datasource.setPassword("IAMNORAT"); // Get a PooledConnection and get the connection handle to the database. AS400JDBCPooledConnection pooledConnection = datasource.getPooledConnection(); Connection connection = pooledConnection.getConnection(); ... work with the connection handle. // Close the connection handle to make available for reuse (physical connection not closed). connection.close(); // Reuse the connection somewhere else. Connection reusedConnection = pooledConnection.getConnection(); ... work with the connection handle. reusedConnection.close(); // Close the physical connection. pooledConnection.close();
AS400JDBCPooledConnection objects generate the following events:
Method Summary | |
---|---|
void |
addConnectionEventListener(ConnectionEventListener listener)
Adds a ConnectionEventListener. |
void |
addStatementEventListener(StatementEventListener listener)
Registers a StatementEventListener with this PooledConnection object. |
void |
close()
Closes the physical connection. |
void |
closeAll()
Closes all the Statement objects that have been opened by this PooledConnection object. |
boolean |
equals(Object obj)
|
Connection |
getConnection()
Returns the connection handle to the database. |
long |
getInactivityTime()
Returns the elapsed time the connection has been idle waiting in the pool. |
long |
getInUseTime()
Returns the elapsed time the connection has been in use. |
long |
getLifeSpan()
Returns the elapsed time the pooled connection has been alive. |
int |
getUseCount()
Returns the number of times the pooled connection has been used. |
int |
hashCode()
|
boolean |
isInUse()
Indicates if the pooled connection is in use. |
void |
removeConnectionEventListener(ConnectionEventListener listener)
Removes a ConnectionEventListener. |
void |
removeStatementEventListener(StatementEventListener listener)
Removes the specified StatementEventListener from the list of
components that will be notified when the driver detects that a
PreparedStatement has been closed or is invalid. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void addConnectionEventListener(ConnectionEventListener listener)
addConnectionEventListener
in interface PooledConnection
listener
- The listener.public void close() throws SQLException
close
in interface PooledConnection
SQLException
- If an error occurs closing the connection.public void closeAll() throws SQLException
SQLException
- Always thrown because this method is not supported.public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public Connection getConnection() throws SQLException
getConnection
in interface PooledConnection
SQLException
- If a database error occurs or if this PooledConnection is already in use.public long getInactivityTime()
public long getInUseTime()
public long getLifeSpan()
public int getUseCount()
public boolean isInUse()
public void removeConnectionEventListener(ConnectionEventListener listener)
removeConnectionEventListener
in interface PooledConnection
listener
- The listener to be removed.public void addStatementEventListener(StatementEventListener listener)
StatementEventListener
with this PooledConnection
object. Components that
wish to be notified when PreparedStatement
s created by the
connection are closed or are detected to be invalid may use this method
to register a StatementEventListener
with this PooledConnection
object.
addStatementEventListener
in interface PooledConnection
listener
- an component which implements the StatementEventListener
interface that is to be registered with this PooledConnection
objectpublic void removeStatementEventListener(StatementEventListener listener)
StatementEventListener
from the list of
components that will be notified when the driver detects that a
PreparedStatement
has been closed or is invalid.
removeStatementEventListener
in interface PooledConnection
listener
- the component which implements the
StatementEventListener
interface that was previously
registered with this PooledConnection
object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |