public interface PooledConnection
PooledConnection对象表示到数据源的物理连接。该连接可以回收,而不是被关闭时,一个应用程序完成,从而减少了连接的数量,需要作出。
一个应用程序不直接使用PooledConnection界面;相反,它是由中间层基础设施管理连接池的应用。
当应用程序调用的方法DataSource.getConnection,它返回一个Connection对象。如果连接池是怎么做的,那Connection对象实际上是一个PooledConnection对象的句柄,它是一个物理连接。
连接池管理器,通常应用程序服务器维护一个游泳池,PooledConnection对象。如果池中有一个PooledConnection对象可用,连接池管理器返回一个对象,是一个Connection物理连接句柄。如果没有PooledConnection对象可用,连接池管理器调用ConnectionPoolDataSource方法getPoolConnection创建新的物理连接。JDBC驱动程序实现ConnectionPoolDataSource创建一个新的PooledConnection对象并返回一个句柄它。
当应用程序关闭连接,它调用的方法close Connection。当连接池时,连接池管理器通知,因为它本身已经注册为使用ConnectionPool方法addConnectionEventListener ConnectionEventListener对象。连接池管理器关闭手柄的PooledConnection对象并返回PooledConnection对象连接池可再次使用。因此,当一个应用程序关闭它的连接时,底层的物理连接将被循环使用,而不是被关闭。
物理连接不关闭连接池管理器调用PooledConnection方法close。这种方法通常被称为如果一个致命的错误使得连接不可用的有一个有序的关闭服务器或。
一个连接池管理器也往往是语句池经理,保持池PreparedStatement对象。当应用程序关闭时一个准备好的声明中,它调用的方法close PreparedStatement。当Statement池时,池经理通知,因为它本身已经注册为使用ConnectionPool方法addStatementEventListener StatementEventListener对象。因此,当应用程序关闭其PreparedStatement,底层的声明是再生而不是闭合。
| Modifier and Type | Method and Description |
|---|---|
void |
addConnectionEventListener(ConnectionEventListener listener)
注册了事件监听器,它会将这
PooledConnection对象当一个事件发生时。
|
void |
addStatementEventListener(StatementEventListener listener)
注册这个
PooledConnection对象
StatementEventListener。
|
void |
close()
关闭,这
PooledConnection对象代表的物理连接。
|
Connection |
getConnection()
创建并返回一个
Connection对象,这个对象代表一个
PooledConnection物理连接句柄。
|
void |
removeConnectionEventListener(ConnectionEventListener listener)
从组件将被通知在这
PooledConnection对象当一个事件发生时,列表中删除给定的事件监听器。
|
void |
removeStatementEventListener(StatementEventListener listener)
从组件时会通知驱动程序检测到一个
PreparedStatement已经关闭或无效的列表中移除指定的
StatementEventListener。
|
Connection getConnection() throws SQLException
Connection对象,这个对象代表一个
PooledConnection物理连接句柄。连接池管理器调用此方法时,应用程序调用的方法
DataSource.getConnection没有
PooledConnection对象可用。看到
interface description更多信息。
Connection对象,是一本
PooledConnection对象句柄
SQLException -如果一个数据库访问错误发生
SQLFeatureNotSupportedException如果JDBC驱动程序不支持此方法
void close()
throws SQLException
PooledConnection对象代表的物理连接。应用程序从不直接调用这个方法;它是由连接池模块调用的,或管理器调用的。
看到interface description更多信息。
SQLException -如果一个数据库访问错误发生
SQLFeatureNotSupportedException如果JDBC驱动程序不支持此方法
void addConnectionEventListener(ConnectionEventListener listener)
PooledConnection对象当一个事件发生时。
listener -的一部分,通常连接池管理器,已实施
ConnectionEventListener接口,要通知当连接关闭或有错误
removeConnectionEventListener(javax.sql.ConnectionEventListener)
void removeConnectionEventListener(ConnectionEventListener listener)
PooledConnection对象当一个事件发生时,列表中删除给定的事件监听器。
listener -的一部分,通常连接池管理器,已实施
ConnectionEventListener接口和登记本
PooledConnection对象作为一个听众
addConnectionEventListener(javax.sql.ConnectionEventListener)
void addStatementEventListener(StatementEventListener listener)
PooledConnection对象
StatementEventListener。组件,希望当由连接创建
PreparedStatements闭合或检测无效,可能用这种方法来与这
PooledConnection对象登记一个
StatementEventListener通知。
listener -它实现了
StatementEventListener接口,能与这个
PooledConnection对象
注册一个组件
void removeStatementEventListener(StatementEventListener listener)
PreparedStatement已经关闭或无效的列表中移除指定的
StatementEventListener。
listener -它实现了
StatementEventListener接口以前注册这个
PooledConnection对象
组件
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.