Package edu.ucsb.nceas.metacat.database
Class DBConnection
java.lang.Object
edu.ucsb.nceas.metacat.database.DBConnection
A class represent a connection object, it includes connection itself,
index, status, age, createtime, connection time, usageCount, warning message
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close a DBConnection objectvoidcommit()Method to make a commit commandDeprecated.PreparedStatements are preferred so as to encourage parameter value bindinglonggetAge()get the db connetion age from the objectget the the name of method checked out the connection from the objectintget the check out serial numberlongget the when a db connetion was checked outget the connetion from the objectlongget the how long db connetion used for the objectlongget the db connetion created time from the objectMethod to get meta dataintget the db connetion status from the objectgetTag()get the db connetion tag from the objectintget the db connetion usage times from the objectget the db connetion waring message from the objectvoidincreaseCheckOutSerialNumber(int myCheckOutSerialNumber) Increase a usage number to this objectvoidincreaseUsageCount(int myUsageCount) Increase a usage number to this objectstatic ConnectionMethod to establish DBConnectionprepareStatement(String sql) Method to create a PreparedStatement by sending a sql statementvoidrollback()Method to roll backvoidsetAge(long myAge) Set a connection age to this objectvoidsetAutoCommit(boolean autoCommit) Method to set commit modevoidsetCheckOutMethodName(String myCheckOutMethodName) Set a method name to the checkOutMethodNamevoidsetCheckOutSerialNumber(int myCheckOutSerialNumber) Set check out serial number to this objectvoidsetCheckOutTime(long myCheckOutTime) Set check out time to this objectvoidsetConnections(Connection myConnection) Set a connection to this objectvoidsetConnectionTime(long myConnectionTime) Set a connection time to this object It is accumulatedvoidsetCreateTime(long myCreateTime) Set a usage number to this objectvoidsetStatus(int myStatus) Set a connection status to this objectvoidSet a connection status to this objectvoidsetUsageCount(int myUsageCount) Set a usage number to this objectvoidsetWarningMessage(SQLWarning myWarningMessage) Set a warning message to this objectstatic voidtestConnection(String dbDriver, String connection, String user, String password) Method to test a JDBC database connection
-
Constructor Details
-
DBConnection
Default constructor of the DBConnection class- Throws:
SQLException
-
-
Method Details
-
getConnections
get the connetion from the object -
setConnections
Set a connection to this object- Parameters:
myDBConnection- , the connection which will be assign to this object
-
getTag
get the db connetion tag from the object -
setTag
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
get the db connetion waring message from the object- Throws:
SQLException
-
setWarningMessage
Set a warning message to this object- Parameters:
myWarningMessage- , the waring which will be assign to this object
-
getCheckOutMethodName
get the the name of method checked out the connection from the object -
setCheckOutMethodName
Set a method name to the checkOutMethodName- Parameters:
myCheckOutMethodName- , the name of method will assinged to it
-
close
Close a DBConnection object- Throws:
SQLException
-
openConnection
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 driverconnection- the string representing the database connectin parametersuser- name of the user to use for database connectionpassword- password for the user to use for database connection- Throws:
SQLException
-
prepareStatement
Method to create a PreparedStatement by sending a sql statement- Throws:
SQLException
-
createStatement
Deprecated.PreparedStatements are preferred so as to encourage parameter value bindingMethod to create a Statement- Throws:
SQLException
-
commit
Method to make a commit command- Throws:
SQLException
-
setAutoCommit
Method to set commit mode- Parameters:
autocommit- , true of false to auto commit- Throws:
SQLException
-
rollback
Method to roll back- Throws:
SQLException
-
getMetaData
Method to get meta data- Throws:
SQLException
-