📄 connectionwrapper.java
字号:
/** * $RCSfile$ * $Revision: 37 $ * $Date: 2004-10-20 23:08:43 -0700 (Wed, 20 Oct 2004) $ * * Copyright (C) 2004 Jive Software. All rights reserved. * * This software is published under the terms of the GNU Public License (GPL), * a copy of which is included in this distribution. */package org.jivesoftware.database;import org.jivesoftware.database.AbstractConnection;import org.jivesoftware.database.ConnectionPool;import java.sql.Connection;import java.sql.SQLException;/** * An implementation of the Connection interface that wraps an underlying * Connection object. It releases the connection back to a connection pool * when Connection.close() is called. * * @author Jive Software */public class ConnectionWrapper extends AbstractConnection { public ConnectionPool pool; public boolean checkedout = false; public long createTime; public long lockTime; public long checkinTime; public Exception exception; public boolean hasLoggedException = false; public ConnectionWrapper(Connection connection, ConnectionPool pool) { super(connection); this.pool = pool; createTime = System.currentTimeMillis(); lockTime = createTime; checkinTime = lockTime; } public void setConnection(Connection connection) { super.connection = connection; } /** * Instead of closing the underlying connection, we simply release * it back into the pool. */ public void close() throws SQLException { synchronized (this) { checkedout = false; checkinTime = System.currentTimeMillis(); } pool.freeConnection(); // Release object references. Any further method calls on the connection will fail. // super.connection = null; } public String toString() { if (connection != null) { return connection.toString(); } else { return "Jive Software Connection Wrapper"; } } public synchronized boolean isCheckedOut() { return checkedout; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -