Index: src/edu/ucsb/nceas/metacat/DBConnection.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBConnection.java	(revision 1087)
+++ src/edu/ucsb/nceas/metacat/DBConnection.java	(revision 1088)
@@ -33,26 +33,42 @@
 
 /**
  * A class represent a connection object, it includes connection itself, 
- * index, status, age, usageCount, warning message
+ * index, status, age, createtime, connection time, usageCount, warning message
  */
  
  public class DBConnection
 {
   private Connection conn;
-  private int status;
+  private String tag;//to idenify this object
+  private int status;// free or using
   private long age;
-  private int usageCount;
+  private long createTime;
+  private long connectionTime; //how long it use for connections, 
+                               //it is accumulated
+  private long checkOutTime;
+  private int usageCount;// how many time the connection was used
   private SQLWarning warningMessage;
   
+  
+  private String  DBDriver=MetaCatUtil.getOption("dbDriver");
+  private String  DBConnectedJDBC=MetaCatUtil.getOption("defaultDB");
+  private String  userName=MetaCatUtil.getOption("user");
+  private String  passWord=MetaCatUtil.getOption("password");
+  
   /**
-   * default constructor of the DBConnection class 
-   *
+   * Default constructor of the DBConnection class 
+   * It will create a new DBConnection with a new Connection
+   * 
    */
-  public DBConnection()
+  public DBConnection() throws SQLException
   {
-    conn = null;
+    conn = openConnection();
+    tag = conn.toString();
     status = 0;
     age = 0;
+    createTime = System.currentTimeMillis();
+    connectionTime = 0;
+    checkOutTime = 0;
     usageCount= 0;
     warningMessage = null;
     
@@ -66,13 +82,16 @@
    * @param age,the age of the connection 
    * @param usageCount of the connection
    */
-  public DBConnection (Connection conn, int status, int myAge, 
-                                                      int usageCount)
+  public DBConnection (Connection conn, int status, long age, 
+                        long createTime, long connectionTime, int usageCount)
                                throws SQLException
   {
     this.conn = conn;
+    this.tag = conn.toString();
     this.status = status;
     this.age = age;
+    this.createTime = createTime;
+    this.connectionTime = connectionTime;
     this.usageCount = usageCount;
     try
     {
@@ -85,9 +104,9 @@
   }
   
   /**
-   * get the db connetion from the object
+   * get the  connetion from the object
    */
-  public Connection getDBConnection()
+  public Connection getConnection()
   {
     return conn;
   }
@@ -96,12 +115,29 @@
    * Set a connection to this object
    * @param myDBConnection, the connection which will be assign to this object
    */
-  public void setDBConnection( Connection myDBConnection)
+  public void setConnection( Connection myConnection)
   {
-    this.conn = myDBConnection;
+    this.conn = myConnection;
   }
-   
+
   /**
+   * get the db connetion tag from the object
+   */
+  public String getTag()
+  {
+    return tag;
+  }
+  
+  /**
+   * Set a connection status to this object
+   * @param myTag, the tag which will be assign to this object
+   */
+  public void setTag(String myTag)
+  {
+    this.tag = myTag;
+  }
+  
+  /**
    * get the db connetion status from the object
    */
   public int getStatus()
@@ -124,9 +160,10 @@
    */
   public long getAge()
   {
-    return age;
+    return (System.currentTimeMillis() - createTime);
   }
   
+ 
   /**
    * Set a connection age to this object
    * @param myAge, the Age which will be assign to this object
@@ -136,8 +173,64 @@
     this.age = myAge;
   }  
   
+  /**
+   * get the db connetion created time from the object
+   */
+  public long getCreateTime()
+  {
+    return createTime;
+  }
   
   /**
+   * Set a usage number to this object
+   * @param myCreateTime, the create time which will be assign to this object
+   */
+  public void setCreateTime(long myCreateTime)
+  {
+    this.createTime = myCreateTime;
+  }
+  
+  /**
+   * get the how long db connetion usedfrom the object
+   */
+  public long getConnectionTime()
+  {
+    return connectionTime;
+  }
+  
+ 
+  /**
+   * Set a connection time to this object
+   * It is accumulated
+   * @param myConnectionTime, the connection time which will assign to
+   * this object
+   */
+  public void setConnectionTime(long myConnectionTime)
+  {
+    this.connectionTime = this.connectionTime + myConnectionTime;
+  }
+  
+    /**
+   * get the how long db connetion usedfrom the object
+   */
+  public long getCheckOutTime()
+  {
+    return checkOutTime;
+  }
+  
+ 
+  /**
+   * Set check out time to this object
+  
+   * @param myCheckOutTime, the check out time which will assign to
+   * this object
+   */
+  public void setCheckOutTime(long myCheckOutTime)
+  {
+    this.checkOutTime = myCheckOutTime;
+  }
+  
+  /**
    * get the db connetion usage times from the object
    */
   public int getUsageCount()
@@ -144,7 +237,8 @@
   {
     return usageCount;
   }
-  
+   
+ 
   /**
    * Set a usage number to this object
    * @param myUsageCount, number of usage which will be assign to this object
@@ -155,6 +249,16 @@
   }
   
   /**
+   * Increase a usage number to this object
+   * @param myUsageCount, number of usage which will be add to this object
+   */
+  public void increaseUsageCount(int myUsageCount)
+  {
+    this.usageCount = this.usageCount + myUsageCount;
+  }  
+  
+  
+  /**
    * get the db connetion waring message from the object
    */
   public SQLWarning getWarningMessage()
@@ -171,5 +275,59 @@
      this.warningMessage = myWarningMessage;
   }
   
+  /**
+   * Close a DBConnection object
+   */
+  public void close() throws SQLException
+  {
+    conn.close();
+    conn=null;
+    tag = null;
+    status = 0;
+    age = 0;
+    createTime = System.currentTimeMillis();
+    connectionTime = 0;
+    checkOutTime = 0;
+    usageCount= 0;
+    warningMessage = null;
+  }
   
+    /** 
+   * Method to establish a JDBC database connection 
+   */
+  private Connection openConnection()
+                  throws SQLException 
+  {
+    return openConnection(DBDriver, DBConnectedJDBC, userName, passWord);
+  }//openDBConnection
+
+  /** 
+   * Method to establish a JDBC database connection 
+   *
+   * @param dbDriver the string representing the database driver
+   * @param connection the string representing the database connectin parameters
+   * @param user name of the user to use for database connection
+   * @param password password for the user to use for database connection
+   */
+  private Connection openConnection(String dbDriver, String connection,
+                String user, String password)
+                throws SQLException
+ {
+
+     // Load the Oracle JDBC driver
+     try
+     {
+       Class.forName (dbDriver);
+     }
+     catch (ClassNotFoundException e)
+     {
+       MetaCatUtil.debugMessage("Error in DBConnectionPool "+e.getMessage(),30);
+       return null;
+     }
+     // Connect to the database
+     Connection conn = DriverManager.getConnection( connection, user, password);
+     return conn;
+  }//OpenDBConnection
+
+  
 }//DBConnection class
