本文整理匯總了Java中javax.sql.PooledConnection.close方法的典型用法代碼示例。如果您正苦於以下問題:Java PooledConnection.close方法的具體用法?Java PooledConnection.close怎麽用?Java PooledConnection.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sql.PooledConnection
的用法示例。
在下文中一共展示了PooledConnection.close方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dispose
import javax.sql.PooledConnection; //導入方法依賴的package包/類
/**
* Closes all unused pooled connections.
*/
public synchronized void dispose() throws SQLException {
if (isDisposed) {
return;
}
isDisposed = true;
SQLException e = null;
while (!recycledConnections.isEmpty()) {
PooledConnection pconn = recycledConnections.remove();
try {
pconn.close();
} catch (SQLException e2) {
if (e == null) {
e = e2;
}
}
}
if (e != null) {
throw e;
}
}
示例2: closePhysically
import javax.sql.PooledConnection; //導入方法依賴的package包/類
private void closePhysically(PooledConnection source, String logText) {
try {
source.close();
} catch (SQLException e) {
logInfo("Error " + logText, e);
}
}
示例3: testBug62452WithConnection
import javax.sql.PooledConnection; //導入方法依賴的package包/類
private void testBug62452WithConnection(PooledConnection con) throws Exception {
this.pstmt = con.getConnection().prepareStatement("SELECT 1");
this.rs = this.pstmt.executeQuery();
con.close();
// If PooledConnection is already closed by some reason a NullPointerException was thrown on the next line
// because the closed connection has nulled out the list that it synchronises on when the closed event is fired.
this.pstmt.close();
}
示例4: testBug4808
import javax.sql.PooledConnection; //導入方法依賴的package包/類
/**
* Tests fix for BUG#4808- Calling .close() twice on a PooledConnection
* causes NPE.
*
* @throws Exception
* if an error occurs.
*/
public void testBug4808() throws Exception {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL(BaseTestCase.dbUrl);
PooledConnection closeMeTwice = ds.getPooledConnection();
closeMeTwice.close();
closeMeTwice.close();
}
示例5: closeConnectionAndIgnoreException
import javax.sql.PooledConnection; //導入方法依賴的package包/類
private void closeConnectionAndIgnoreException(PooledConnection pconn) {
try {
pconn.close();
} catch (SQLException e) {
log("Error while closing database connection: " + e.toString());
}
}