public class DBConnection
extends java.lang.Object
Constructor and Description |
---|
DBConnection()
Default constructor of the DBConnection class
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close a DBConnection object
|
void |
commit()
Method to make a commit command
|
java.sql.Statement |
createStatement()
Deprecated.
PreparedStatements are preferred so as to encourage
parameter value binding
|
long |
getAge()
get the db connetion age from the object
|
java.lang.String |
getCheckOutMethodName()
get the the name of method checked out the connection from the object
|
int |
getCheckOutSerialNumber()
get the check out serial number
|
long |
getCheckOutTime()
get the when a db connetion was checked out
|
java.sql.Connection |
getConnections()
get the connetion from the object
|
long |
getConnectionTime()
get the how long db connetion used for the object
|
long |
getCreateTime()
get the db connetion created time from the object
|
java.sql.DatabaseMetaData |
getMetaData()
Method to get meta data
|
int |
getStatus()
get the db connetion status from the object
|
java.lang.String |
getTag()
get the db connetion tag from the object
|
int |
getUsageCount()
get the db connetion usage times from the object
|
java.sql.SQLWarning |
getWarningMessage()
get the db connetion waring message from the object
|
void |
increaseCheckOutSerialNumber(int myCheckOutSerialNumber)
Increase a usage number to this object
|
void |
increaseUsageCount(int myUsageCount)
Increase a usage number to this object
|
static java.sql.Connection |
openConnection()
Method to establish DBConnection
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Method to create a PreparedStatement by sending a sql statement
|
void |
rollback()
Method to roll back
|
void |
setAge(long myAge)
Set a connection age to this object
|
void |
setAutoCommit(boolean autoCommit)
Method to set commit mode
|
void |
setCheckOutMethodName(java.lang.String myCheckOutMethodName)
Set a method name to the checkOutMethodName
|
void |
setCheckOutSerialNumber(int myCheckOutSerialNumber)
Set check out serial number to this object
|
void |
setCheckOutTime(long myCheckOutTime)
Set check out time to this object
|
void |
setConnections(java.sql.Connection myConnection)
Set a connection to this object
|
void |
setConnectionTime(long myConnectionTime)
Set a connection time to this object
It is accumulated
|
void |
setCreateTime(long myCreateTime)
Set a usage number to this object
|
void |
setStatus(int myStatus)
Set a connection status to this object
|
void |
setTag(java.lang.String myTag)
Set a connection status to this object
|
void |
setUsageCount(int myUsageCount)
Set a usage number to this object
|
void |
setWarningMessage(java.sql.SQLWarning myWarningMessage)
Set a warning message to this object
|
static void |
testConnection(java.lang.String dbDriver,
java.lang.String connection,
java.lang.String user,
java.lang.String password)
Method to test a JDBC database connection
|
public DBConnection() throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection getConnections()
public void setConnections(java.sql.Connection myConnection)
myDBConnection,
- the connection which will be assign to this objectpublic java.lang.String getTag()
public void setTag(java.lang.String myTag)
myTag,
- the tag which will be assign to this objectpublic int getStatus()
public void setStatus(int myStatus)
myStatus,
- the status which will be assign to this object
0 is free, 1 is usingpublic long getAge()
public void setAge(long myAge)
myAge,
- the Age which will be assign to this objectpublic long getCreateTime()
public void setCreateTime(long myCreateTime)
myCreateTime,
- the create time which will be assign to this objectpublic long getConnectionTime()
public void setConnectionTime(long myConnectionTime)
myConnectionTime,
- the connection time which will assign to
this objectpublic long getCheckOutTime()
public void setCheckOutTime(long myCheckOutTime)
myCheckOutTime,
- the check out time which will assign to
this objectpublic int getUsageCount()
public void setUsageCount(int myUsageCount)
myUsageCount,
- number of usage which will be assign to this objectpublic void increaseUsageCount(int myUsageCount)
myUsageCount,
- number of usage which will be add to this objectpublic int getCheckOutSerialNumber()
public void setCheckOutSerialNumber(int myCheckOutSerialNumber)
myCheckOutSerialNumber,
- the check out serial number which will
assign to this objectpublic void increaseCheckOutSerialNumber(int myCheckOutSerialNumber)
myUsageCount,
- number of usage which will be add to this objectpublic java.sql.SQLWarning getWarningMessage() throws java.sql.SQLException
java.sql.SQLException
public void setWarningMessage(java.sql.SQLWarning myWarningMessage)
myWarningMessage,
- the waring which will be assign to this objectpublic java.lang.String getCheckOutMethodName()
public void setCheckOutMethodName(java.lang.String myCheckOutMethodName)
myCheckOutMethodName,
- the name of method will assinged to itpublic void close() throws java.sql.SQLException
java.sql.SQLException
public static java.sql.Connection openConnection() throws java.sql.SQLException
java.sql.SQLException
public static void testConnection(java.lang.String dbDriver, java.lang.String connection, java.lang.String user, java.lang.String password) throws java.sql.SQLException
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 connectionjava.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public java.sql.Statement createStatement() throws java.sql.SQLException
java.sql.SQLException
public void commit() throws java.sql.SQLException
java.sql.SQLException
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException
autocommit,
- true of false to auto commitjava.sql.SQLException
public void rollback() throws java.sql.SQLException
java.sql.SQLException
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
java.sql.SQLException
Copyright © 2020 Regents of the University of California. All Rights Reserved.