|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> sql >> [ standard overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.lutris.appserver.server.sql.standard
Class StandardDBConnection

java.lang.Objectcom.lutris.appserver.server.sql.standard.StandardDBConnection
- All Implemented Interfaces:
- com.lutris.appserver.server.sql.DBConnection
- public class StandardDBConnection
- extends java.lang.Object
- implements com.lutris.appserver.server.sql.DBConnection
- extends java.lang.Object
Standard implementation of the DBConnection object.
- Since:
- LBS1.7
- Version:
- $Revision: 1.13.4.1 $
| Field Summary | |
private boolean |
allocated
|
private boolean |
closed
|
protected java.sql.Connection |
connection
JDBC connection object. |
protected com.lutris.appserver.server.sql.ConnectionAllocator |
connectionAllocator
|
private java.sql.Statement |
currentStmt
|
private boolean |
dropConnection
|
private boolean |
dropped
|
private int |
generation
|
private int |
id
|
private com.lutris.logging.LogChannel |
log
The log channel. |
private boolean |
logging
|
private int |
maxPreparedStmts
|
private static int |
nextId
|
protected java.lang.String |
password
Database user password. |
private java.util.Hashtable |
preparedStmtCache
|
private 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 |
StandardDBConnection(com.lutris.appserver.server.sql.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. |
private void |
allocatedCheck()
Check to see that this database connection has has been properly allocated before is is used. |
void |
close()
Close this connection. |
private void |
closedCheck()
Check to see that this database connection has has not been closed. |
void |
commit()
Commit a transaction. |
private 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. |
int |
getGeneration()
Get the generation number specified when the connection was created. |
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. |
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. |
void |
release()
Return this connection to its allocator. |
void |
reset()
Closes down all query-specific resources. |
private 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 |
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 |
connection
protected java.sql.Connection connection
- JDBC connection object.
url
protected java.lang.String url
- Database URL, used for error messages.
user
protected java.lang.String user
- Database user, for error messages.
password
protected java.lang.String password
- Database user password.
id
private int id
nextId
private static int nextId
preparedStmtCache
private java.util.Hashtable preparedStmtCache
currentStmt
private java.sql.Statement currentStmt
connectionAllocator
protected com.lutris.appserver.server.sql.ConnectionAllocator connectionAllocator
logging
private boolean logging
generation
private int generation
closed
private boolean closed
dropConnection
private boolean dropConnection
dropped
private boolean dropped
reset
private boolean reset
allocated
private boolean allocated
maxPreparedStmts
private int maxPreparedStmts
log
private com.lutris.logging.LogChannel log
- The log channel.
| Constructor Detail |
StandardDBConnection
protected StandardDBConnection(com.lutris.appserver.server.sql.ConnectionAllocator connectionAllocatorObj, java.lang.String url, java.lang.String user, java.lang.String password, int maxPreparedStatements, boolean logging, int generation) throws java.sql.SQLException
- Initialize the connection to a database.
| Method Detail |
allocate
public void allocate()
throws java.sql.SQLException
- Method called when this connection object is allocated from the
connection allocator.
- Specified by:
allocatein interfacecom.lutris.appserver.server.sql.DBConnection
resetCheck
private void resetCheck()
throws java.sql.SQLException
- Check to see that the previous database connection
has had reset called. This ensures that the database
resources have always been freed in a timely manner.
allocatedCheck
private void allocatedCheck()
throws java.sql.SQLException
- Check to see that this database connection has
has been properly allocated before is is used.
closedCheck
private void closedCheck()
throws java.sql.SQLException
- Check to see that this database connection has
has not been closed.
validate
public void validate()
throws java.sql.SQLException
- Validates this connection. Check to see that it
is not closed and has been properly allocated.
- Specified by:
validatein interfacecom.lutris.appserver.server.sql.DBConnection
reset
public void reset()
throws java.sql.SQLException
- Closes down all query-specific resources.
- Specified by:
resetin interfacecom.lutris.appserver.server.sql.DBConnection
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
- Get a prepared statement given an SQL string. If the statement is
cached, return that statement, otherwise prepare and save in the
cache.
- Specified by:
prepareStatementin interfacecom.lutris.appserver.server.sql.DBConnection
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
- Creates a CallableStatement object for calling database
stored procedures. Refer to jdk api refernece.
- Specified by:
prepareCallin interfacecom.lutris.appserver.server.sql.DBConnection
executeQuery
public java.sql.ResultSet executeQuery(java.sql.PreparedStatement preparedStmt, java.lang.String msg) throws java.sql.SQLException
- Execute a prepared query statement. Once the query has completed,
reset()should be called.- Specified by:
executeQueryin interfacecom.lutris.appserver.server.sql.DBConnection
executeQuery
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException
- Execute a SQL query statement. This is a wrapper that adds logging.
Once the query has completed,
reset()should be called.- Specified by:
executeQueryin interfacecom.lutris.appserver.server.sql.DBConnection
executeUpdate
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException
- Execute a SQL update statement. This is a wrapper that adds logging.
Once the update has completed,
reset()should be called.- Specified by:
executeUpdatein interfacecom.lutris.appserver.server.sql.DBConnection
executeUpdate
public int executeUpdate(java.sql.PreparedStatement preparedStmt, java.lang.String msg) throws java.sql.SQLException
- Execute a prepared update statement. Once the update has completed,
reset()should be called.- Specified by:
executeUpdatein interfacecom.lutris.appserver.server.sql.DBConnection
execute
public boolean execute(java.lang.String sql) throws java.sql.SQLException
- Execute a SQL statement that does not return a resultset. This is a
wrapper that adds logging. Once the query has completed,
reset()should be called.- Specified by:
executein interfacecom.lutris.appserver.server.sql.DBConnection
warningCheck
public void warningCheck(java.sql.ResultSet resultSet) throws java.sql.SQLException
- Check for warnings in a result set.
- Specified by:
warningCheckin interfacecom.lutris.appserver.server.sql.DBConnection
release
public void release()
- Return this connection to its allocator. This object should not be
used after calling this function.
- Specified by:
releasein interfacecom.lutris.appserver.server.sql.DBConnection
drop
private void drop()
- Drop this connection from the connection allocator.
handleException
public boolean handleException(java.sql.SQLException sqlExcept)
- Check if a connection is valid after an SQL exception
is thrown. If it is not usable, then the connection is
dropped from the connection allocator and closed. The connection
is then no longer usable.
- Specified by:
handleExceptionin interfacecom.lutris.appserver.server.sql.DBConnection
getGeneration
public int getGeneration()
- Get the generation number specified when the connection was created.
- Specified by:
getGenerationin interfacecom.lutris.appserver.server.sql.DBConnection
close
public void close()
- Close this connection. Use by the connection allocator when this
object is no longer used. Errors are ignored.
- Specified by:
closein interfacecom.lutris.appserver.server.sql.DBConnection
setAutoCommit
public void setAutoCommit(boolean on)
throws java.sql.SQLException
- Autocommit on/off.
- Specified by:
setAutoCommitin interfacecom.lutris.appserver.server.sql.DBConnection
commit
public void commit()
throws java.sql.SQLException
- Commit a transaction.
- Specified by:
commitin interfacecom.lutris.appserver.server.sql.DBConnection
rollback
public void rollback()
throws java.sql.SQLException
- Rollback a transaction. Should only be used when
auto-commit mode
has been disabled.
- Specified by:
rollbackin interfacecom.lutris.appserver.server.sql.DBConnection
logDebug
protected void logDebug(java.lang.String str)
- Debug logging.
logDebug
protected void logDebug(java.lang.String str, java.sql.Statement stmt)
- Debug logging.
incrRequestCount
public void incrRequestCount()
- Increment the count of the number of requests against
this connection.
- Specified by:
incrRequestCountin interfacecom.lutris.appserver.server.sql.DBConnection
getUrl
public java.lang.String getUrl()
- Get the database URL.
- Specified by:
getUrlin interfacecom.lutris.appserver.server.sql.DBConnection
getUser
public java.lang.String getUser()
- Get the database user name. Normally user for error messages.
- Specified by:
getUserin interfacecom.lutris.appserver.server.sql.DBConnection
getConnection
public java.sql.Connection getConnection()
- Get the underlying
Connectionobject. Use with extreme caution.- Specified by:
getConnectionin interfacecom.lutris.appserver.server.sql.DBConnection
|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> sql >> [ standard overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.lutris.appserver.server.sql.standard.StandardDBConnection