|
DODS 6.5 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lutris.appserver.server.sql.standard.SimpleDBConnection
Standard implementation of the DBConnection object.
DBConnection
Field Summary | |
protected boolean |
allocated
|
protected boolean |
closed
|
protected java.sql.Connection |
connection
JDBC connection object. |
protected ConnectionAllocator |
connectionAllocator
|
protected long |
connectionEnterPoolTime
|
protected int |
connectionUsageCounter
|
protected java.sql.Statement |
currentStmt
|
protected boolean |
dropConnection
|
protected boolean |
dropped
|
protected int |
generation
|
protected int |
id
|
protected boolean |
logging
|
protected int |
maxPreparedStmts
|
protected static int |
nextId
|
protected java.lang.String |
password
Database user password. |
protected java.util.Hashtable |
preparedStmtCache
|
protected boolean |
reset
|
protected java.lang.String |
url
Database URL, used for error messages. |
protected java.lang.String |
user
Database user, for error messages. |
Constructor Summary | |
SimpleDBConnection(ConnectionAllocator connectionAllocatorObj,
java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxPreparedStatements,
boolean logging,
int generation)
Initialize the connection to a database. |
Method Summary | |
void |
allocate()
Method called when this connection object is allocated from the connection allocator. |
protected void |
allocatedCheck()
Check to see that this database connection has has been properly allocated before is is used. |
void |
close()
Close this connection. |
protected void |
closedCheck()
Check to see that this database connection has has not been closed. |
void |
commit()
Commit a transaction. |
protected void |
drop()
Drop this connection from the connection allocator. |
boolean |
execute(java.lang.String sql)
Execute a SQL statement that does not return a resultset. |
java.sql.ResultSet |
executeQuery(java.sql.PreparedStatement preparedStmt,
java.lang.String msg)
Execute a prepared query statement. |
java.sql.ResultSet |
executeQuery(java.lang.String sql)
Execute a SQL query statement. |
int |
executeUpdate(java.sql.PreparedStatement preparedStmt,
java.lang.String msg)
Execute a prepared update statement. |
int |
executeUpdate(java.lang.String sql)
Execute a SQL update statement. |
java.sql.Connection |
getConnection()
Get the underlying Connection object. |
long |
getConnectionEnterPoolTime()
Return value off ConnectionEnterPoolTime. |
int |
getConnectionUsageCounter()
Return value off connectionUsageCounter. |
java.lang.String |
getDatabaseName()
|
int |
getGeneration()
Get the generation number specified when the connection was created. |
int |
getMaxPreparedStmts()
|
protected int |
getResultSetConcurrency()
|
protected int |
getResultSetType()
|
java.lang.String |
getUrl()
Get the database URL. |
java.lang.String |
getUser()
Get the database user name. |
boolean |
handleException(java.sql.SQLException sqlExcept)
Check if a connection is valid after an SQL exception is thrown. |
void |
incrRequestCount()
Increment the count of the number of requests against this connection. |
boolean |
isClosed()
Is connection closed. |
boolean |
isDroped()
Is connection droped. |
boolean |
isMarkedForDrop()
|
protected void |
logDebug(java.lang.String str)
Debug logging. |
protected void |
logDebug(java.lang.String str,
java.sql.Statement stmt)
Debug logging. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
Creates a CallableStatement object for calling database stored procedures. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Get a prepared statement given an SQL string. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int iResultSetType,
int iResultSetConcurrency)
Get a prepared statement given an SQL string. |
void |
release()
Return this connection to its allocator. |
void |
reset()
Closes down all query-specific resources. |
protected void |
resetCheck()
Check to see that the previous database connection has had reset called. |
void |
rollback()
Rollback a transaction. |
void |
setAutoCommit(boolean on)
Autocommit on/off. |
void |
setConnectionEnterPoolTime(long i)
Set new value for ConnectionEnterPoolTime. |
void |
setConnectionUsageCounter(int i)
Set new value for connectionUsageCounter. |
void |
validate()
Validates this connection. |
void |
warningCheck(java.sql.ResultSet resultSet)
Check for warnings in a result set. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.sql.Connection connection
protected java.lang.String url
protected java.lang.String user
protected java.lang.String password
protected int id
protected static int nextId
protected java.util.Hashtable preparedStmtCache
protected java.sql.Statement currentStmt
protected ConnectionAllocator connectionAllocator
protected boolean logging
protected int generation
protected boolean closed
protected boolean dropConnection
protected boolean dropped
protected boolean reset
protected boolean allocated
protected int maxPreparedStmts
protected int connectionUsageCounter
protected long connectionEnterPoolTime
Constructor Detail |
public SimpleDBConnection(ConnectionAllocator connectionAllocatorObj, java.lang.String url, java.lang.String user, java.lang.String password, int maxPreparedStatements, boolean logging, int generation) throws java.sql.SQLException
url
- JDBC URL of database.user
- SQL user name.password
- SQL password.connectionAllocatorObj
- The connection allocator that this
connection belongs to.maxPreparedStatements
- Maximum number of preparse statements.
a value of less than zero queries JDBC for the value.logging
- Specifying true
enables SQL logging.generation
- A generation number used to drop old connection
when they are released.
java.sql.SQLException
- If a connection can't be established.Method Detail |
public void allocate() throws java.sql.SQLException
allocate
in interface DBConnection
java.sql.SQLException
- If reset
had no
been called on the previous operation.protected void resetCheck() throws java.sql.SQLException
java.sql.SQLException
- If reset
has not
been called on the previous operation.protected void allocatedCheck() throws java.sql.SQLException
java.sql.SQLException
- If it was not properly allocated.protected void closedCheck() throws java.sql.SQLException
java.sql.SQLException
- If it is closed.public void validate() throws java.sql.SQLException
validate
in interface DBConnection
java.sql.SQLException
- If it is not valid.public void reset() throws java.sql.SQLException
reset
in interface DBConnection
java.sql.SQLException
- If a database error occurs.public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
prepareStatement
in interface DBConnection
sql
- The SQL statement to prepared.
java.sql.SQLException
- If a SQL error occured compiling the
statement.public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int iResultSetType, int iResultSetConcurrency) throws java.sql.SQLException
prepareStatement
in interface ExtendedDBConnection
sql
- The SQL statement to prepared.iResultSetType
- a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE.iResultSetConcurrency
- a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE.
java.sql.SQLException
- If a SQL error occured compiling the
statement.protected int getResultSetType()
protected int getResultSetConcurrency()
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
prepareCall
in interface DBConnection
sql
- The SQL statement to be called.
java.sql.SQLException
- If a database access error occurs
statement.public java.sql.ResultSet executeQuery(java.sql.PreparedStatement preparedStmt, java.lang.String msg) throws java.sql.SQLException
reset()
should be called.
executeQuery
in interface DBConnection
preparedStmt
- The statement to execute.msg
- for logging/debug purposes
java.sql.SQLException
- If a SQL error occured executing the
statement.public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException
reset()
should be called.
executeQuery
in interface DBConnection
sql
- The SQL query statement
java.sql.SQLException
- If a SQL error occured executing the
statement.public int executeUpdate(java.lang.String sql) throws java.sql.SQLException
reset()
should be called.
executeUpdate
in interface DBConnection
sql
- The SQL query statement
java.sql.SQLException
- If a SQL error occured executing the update.public int executeUpdate(java.sql.PreparedStatement preparedStmt, java.lang.String msg) throws java.sql.SQLException
reset()
should be called.
executeUpdate
in interface DBConnection
preparedStmt
- The statement to execute.msg
- for logging/debug purposes
java.sql.SQLException
- If a SQL error occured executing the
statement.public boolean execute(java.lang.String sql) throws java.sql.SQLException
reset()
should be called.
execute
in interface DBConnection
sql
- The SQL query statement
java.sql.SQLException
- If a SQL error occured executing the
statement.public void warningCheck(java.sql.ResultSet resultSet) throws java.sql.SQLException
warningCheck
in interface DBConnection
resultSet
- The result set to check for warnings.
java.sql.SQLException
- If a SQL error occured compiling the
statement.public void release()
release
in interface DBConnection
protected void drop()
public boolean handleException(java.sql.SQLException sqlExcept)
handleException
in interface DBConnection
sqlExcept
- The SQL exception that occured.
public int getGeneration()
getGeneration
in interface DBConnection
public void close()
close
in interface DBConnection
public void setAutoCommit(boolean on) throws java.sql.SQLException
setAutoCommit
in interface DBConnection
on
- - False to disable auto commit mode. True to enable.
java.sql.SQLException
- If a database access error occurs.public void commit() throws java.sql.SQLException
commit
in interface DBConnection
java.sql.SQLException
- If a database access error occurs.public void rollback() throws java.sql.SQLException
rollback
in interface DBConnection
java.sql.SQLException
- If a database access error occurs.protected void logDebug(java.lang.String str)
str
- The data to log.protected void logDebug(java.lang.String str, java.sql.Statement stmt)
str
- The data to log.stmt
- The statement to log.public void incrRequestCount()
incrRequestCount
in interface DBConnection
public java.lang.String getUrl()
getUrl
in interface DBConnection
public java.lang.String getUser()
getUser
in interface DBConnection
public java.sql.Connection getConnection()
Connection
object.
Use with extreme caution.
getConnection
in interface DBConnection
public boolean isMarkedForDrop()
isMarkedForDrop
in interface DBConnection
public java.lang.String getDatabaseName()
getDatabaseName
in interface DBConnection
public int getConnectionUsageCounter()
ExtendedDBConnection
getConnectionUsageCounter
in interface ExtendedDBConnection
public void setConnectionUsageCounter(int i)
ExtendedDBConnection
setConnectionUsageCounter
in interface ExtendedDBConnection
i
- new value for connectionUsageCounterpublic boolean isDroped()
ExtendedDBConnection
isDroped
in interface ExtendedDBConnection
public boolean isClosed()
ExtendedDBConnection
isClosed
in interface ExtendedDBConnection
public void setConnectionEnterPoolTime(long i)
ExtendedDBConnection
setConnectionEnterPoolTime
in interface ExtendedDBConnection
i
- New value.public long getConnectionEnterPoolTime()
ExtendedDBConnection
getConnectionEnterPoolTime
in interface ExtendedDBConnection
public int getMaxPreparedStmts()
getMaxPreparedStmts
in interface ExtendedDBConnection
|
DODS 6.5 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |