Class DBConnection

java.lang.Object
edu.ucsb.nceas.metacat.database.DBConnection

public class DBConnection extends Object
A class represent a connection object, it includes connection itself, index, status, age, createtime, connection time, usageCount, warning message
  • Constructor Details

    • DBConnection

      public DBConnection() throws SQLException
      Default constructor of the DBConnection class
      Throws:
      SQLException
  • Method Details

    • getConnections

      public Connection getConnections()
      get the connetion from the object
    • setConnections

      public void setConnections(Connection myConnection)
      Set a connection to this object
      Parameters:
      myDBConnection - , the connection which will be assign to this object
    • getTag

      public String getTag()
      get the db connetion tag from the object
    • setTag

      public void setTag(String myTag)
      Set a connection status to this object
      Parameters:
      myTag - , the tag which will be assign to this object
    • getStatus

      public int getStatus()
      get the db connetion status from the object
    • setStatus

      public void setStatus(int myStatus)
      Set a connection status to this object
      Parameters:
      myStatus - , the status which will be assign to this object 0 is free, 1 is using
    • getAge

      public long getAge()
      get the db connetion age from the object
    • setAge

      public void setAge(long myAge)
      Set a connection age to this object
      Parameters:
      myAge - , the Age which will be assign to this object
    • getCreateTime

      public long getCreateTime()
      get the db connetion created time from the object
    • setCreateTime

      public void setCreateTime(long myCreateTime)
      Set a usage number to this object
      Parameters:
      myCreateTime - , the create time which will be assign to this object
    • getConnectionTime

      public long getConnectionTime()
      get the how long db connetion used for the object
    • setConnectionTime

      public void setConnectionTime(long myConnectionTime)
      Set a connection time to this object It is accumulated
      Parameters:
      myConnectionTime - , the connection time which will assign to this object
    • getCheckOutTime

      public long getCheckOutTime()
      get the when a db connetion was checked out
    • setCheckOutTime

      public void setCheckOutTime(long myCheckOutTime)
      Set check out time to this object
      Parameters:
      myCheckOutTime - , the check out time which will assign to this object
    • getUsageCount

      public int getUsageCount()
      get the db connetion usage times from the object
    • setUsageCount

      public void setUsageCount(int myUsageCount)
      Set a usage number to this object
      Parameters:
      myUsageCount - , number of usage which will be assign to this object
    • increaseUsageCount

      public void increaseUsageCount(int myUsageCount)
      Increase a usage number to this object
      Parameters:
      myUsageCount - , number of usage which will be add to this object
    • getCheckOutSerialNumber

      public int getCheckOutSerialNumber()
      get the check out serial number
    • setCheckOutSerialNumber

      public void setCheckOutSerialNumber(int myCheckOutSerialNumber)
      Set check out serial number to this object
      Parameters:
      myCheckOutSerialNumber - , the check out serial number which will assign to this object
    • increaseCheckOutSerialNumber

      public void increaseCheckOutSerialNumber(int myCheckOutSerialNumber)
      Increase a usage number to this object
      Parameters:
      myUsageCount - , number of usage which will be add to this object
    • getWarningMessage

      public SQLWarning getWarningMessage() throws SQLException
      get the db connetion waring message from the object
      Throws:
      SQLException
    • setWarningMessage

      public void setWarningMessage(SQLWarning myWarningMessage)
      Set a warning message to this object
      Parameters:
      myWarningMessage - , the waring which will be assign to this object
    • getCheckOutMethodName

      public String getCheckOutMethodName()
      get the the name of method checked out the connection from the object
    • setCheckOutMethodName

      public void setCheckOutMethodName(String myCheckOutMethodName)
      Set a method name to the checkOutMethodName
      Parameters:
      myCheckOutMethodName - , the name of method will assinged to it
    • close

      public void close() throws SQLException
      Close a DBConnection object
      Throws:
      SQLException
    • openConnection

      public static Connection openConnection() throws SQLException
      Method to establish DBConnection
      Throws:
      SQLException
    • testConnection

      public static void testConnection(String dbDriver, String connection, String user, String password) throws SQLException
      Method to test a JDBC database connection
      Parameters:
      dbDriver - the string representing the database driver
      connection - the string representing the database connectin parameters
      user - name of the user to use for database connection
      password - password for the user to use for database connection
      Throws:
      SQLException
    • prepareStatement

      public PreparedStatement prepareStatement(String sql) throws SQLException
      Method to create a PreparedStatement by sending a sql statement
      Throws:
      SQLException
    • createStatement

      public Statement createStatement() throws SQLException
      Deprecated.
      PreparedStatements are preferred so as to encourage parameter value binding
      Method to create a Statement
      Throws:
      SQLException
    • commit

      public void commit() throws SQLException
      Method to make a commit command
      Throws:
      SQLException
    • setAutoCommit

      public void setAutoCommit(boolean autoCommit) throws SQLException
      Method to set commit mode
      Parameters:
      autocommit - , true of false to auto commit
      Throws:
      SQLException
    • rollback

      public void rollback() throws SQLException
      Method to roll back
      Throws:
      SQLException
    • getMetaData

      public DatabaseMetaData getMetaData() throws SQLException
      Method to get meta data
      Throws:
      SQLException