1 11 12 package org.jivesoftware.database; 13 14 import org.jivesoftware.database.AbstractConnection; 15 import org.jivesoftware.database.ConnectionPool; 16 17 import java.sql.Connection ; 18 import java.sql.SQLException ; 19 20 27 public class ConnectionWrapper extends AbstractConnection { 28 29 public ConnectionPool pool; 30 public boolean checkedout = false; 31 public long createTime; 32 public long lockTime; 33 public long checkinTime; 34 public Exception exception; 35 public boolean hasLoggedException = false; 36 37 public ConnectionWrapper(Connection connection, ConnectionPool pool) { 38 super(connection); 39 40 this.pool = pool; 41 createTime = System.currentTimeMillis(); 42 lockTime = createTime; 43 checkinTime = lockTime; 44 } 45 46 public void setConnection(Connection connection) { 47 super.connection = connection; 48 } 49 50 54 public void close() throws SQLException { 55 synchronized (this) { 56 checkedout = false; 57 checkinTime = System.currentTimeMillis(); 58 } 59 60 pool.freeConnection(); 61 62 } 65 66 public String toString() { 67 if (connection != null) { 68 return connection.toString(); 69 } 70 else { 71 return "Jive Software Connection Wrapper"; 72 } 73 } 74 75 public synchronized boolean isCheckedOut() { 76 return checkedout; 77 } 78 } 79 | Popular Tags |