|
DODS 7.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lutris.appserver.server.sql.ExtendedDBConnection
public abstract class ExtendedDBConnection
Standard implementation of the DBConnection object.
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 PreparedStatementCache |
prepareStatementCache
|
protected int |
psCacheLatency
|
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 | |
---|---|
protected |
ExtendedDBConnection()
|
|
ExtendedDBConnection(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. |
ObjectId |
allocateObjectId(java.lang.String tableName)
Allocates a new object id. |
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()
|
int |
getConnectionUsageCounter()
|
java.lang.String |
getDatabaseName()
|
int |
getGeneration()
Get the generation number specified when the connection was created. |
int |
getMaxPreparedStmts()
|
int |
getResultSetConcurrency()
|
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()
|
boolean |
isDroped()
|
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,
boolean autogenerated)
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. |
abstract 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)
|
void |
setConnectionUsageCounter(int i)
|
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 PreparedStatementCache prepareStatementCache
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
protected int psCacheLatency
Constructor Detail |
---|
public ExtendedDBConnection(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.protected ExtendedDBConnection()
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, boolean autogenerated) throws java.sql.SQLException
sql
- The SQL statement to prepared.autogenerated
- Create new prepared statement with ability
to retrive autogenerated values from database.
java.sql.SQLException
- If a SQL error occured compiling
the statement.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
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.public int getResultSetType()
public 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 abstract 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()
public void setConnectionUsageCounter(int i)
i
- new value for connectionUsageCounterpublic boolean isDroped()
public boolean isClosed()
public void setConnectionEnterPoolTime(long i)
public long getConnectionEnterPoolTime()
public int getMaxPreparedStmts()
public ObjectId allocateObjectId(java.lang.String tableName) throws ObjectIdException
tableName
-
ObjectIdException
|
DODS 7.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |