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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close a DBConnection objectvoid
commit()
Method to make a commit commandDeprecated.PreparedStatements are preferred so as to encourage parameter value bindinglong
getAge()
get the db connetion age from the objectget the the name of method checked out the connection from the objectint
get the check out serial numberlong
get the when a db connetion was checked outget the connetion from the objectlong
get the how long db connetion used for the objectlong
get the db connetion created time from the objectMethod to get meta dataint
get the db connetion status from the objectgetTag()
get the db connetion tag from the objectint
get the db connetion usage times from the objectget the db connetion waring message from the objectvoid
increaseCheckOutSerialNumber
(int myCheckOutSerialNumber) Increase a usage number to this objectvoid
increaseUsageCount
(int myUsageCount) Increase a usage number to this objectstatic Connection
Method to establish DBConnectionprepareStatement
(String sql) Method to create a PreparedStatement by sending a sql statementvoid
rollback()
Method to roll backvoid
setAge
(long myAge) Set a connection age to this objectvoid
setAutoCommit
(boolean autoCommit) Method to set commit modevoid
setCheckOutMethodName
(String myCheckOutMethodName) Set a method name to the checkOutMethodNamevoid
setCheckOutSerialNumber
(int myCheckOutSerialNumber) Set check out serial number to this objectvoid
setCheckOutTime
(long myCheckOutTime) Set check out time to this objectvoid
setConnections
(Connection myConnection) Set a connection to this objectvoid
setConnectionTime
(long myConnectionTime) Set a connection time to this object It is accumulatedvoid
setCreateTime
(long myCreateTime) Set a usage number to this objectvoid
setStatus
(int myStatus) Set a connection status to this objectvoid
Set a connection status to this objectvoid
setUsageCount
(int myUsageCount) Set a usage number to this objectvoid
setWarningMessage
(SQLWarning myWarningMessage) Set a warning message to this objectstatic void
testConnection
(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
-