|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opengts.dbtools.DBConnection
public class DBConnection
DBConnection
provides connections to the SQL server
Field Summary | |
---|---|
static boolean |
ALWAYS_NEW_CONNECTION
|
protected static java.util.Collection<DBConnection> |
dbConnectionList
|
protected static java.util.Map<java.lang.String,DBConnection> |
dbConnectionMap
|
protected static java.util.Map<java.lang.String,java.util.ArrayList<DBConnection>> |
dbConnectionPool
|
Constructor Summary | |
---|---|
protected |
DBConnection(java.lang.String uri,
java.lang.String user,
java.lang.String pass)
Constructor |
Method Summary | |
---|---|
protected java.sql.Statement |
_execute(java.lang.String sql,
boolean rowByRow)
Execute the specified SQL statement |
protected java.sql.ResultSet |
_executeQuery(java.lang.String sql)
Execute the specified SQL query |
protected static void |
_saveDBConnection(DBConnection dbc)
Saves a named DBConnection |
static void |
closeAllConnections()
Close all open DBConnections |
void |
closeConnection()
Closes the current database connection |
java.sql.Statement |
createStatement()
Create a new Statement |
java.sql.Statement |
createStatement(boolean rowByRow)
Create a new Statement |
java.sql.Statement |
execute(java.lang.String sql)
Execute the specified SQL statement |
java.sql.Statement |
execute(java.lang.String sql,
boolean rowByRow)
Execute the specified SQL statement |
java.sql.ResultSet |
executeQuery(java.lang.String sql)
Execute the specified SQL query |
void |
executeUpdate(java.lang.String sql)
Execute the specified SQL update |
long |
executeUpdate(java.lang.String sql,
boolean rtnAutoIncrVal)
Execute the specified SQL update |
protected void |
finalize()
|
java.sql.Connection |
getConnection()
Returns a database connection |
static DBConnection |
getDBConnection(java.lang.String uri,
java.lang.String user,
java.lang.String pass)
Gets a DBConnection based on the specified URI |
static DBConnection |
getDefaultConnection()
Gets the default DBConnection |
java.lang.String |
getPassword()
Gets the connection user password |
static boolean |
getShowExecutedSQL()
Returns true if SQL statements should be displayed |
java.lang.String |
getUri()
Gets the connection URI |
java.lang.String |
getUser()
Gets the connection user |
boolean |
isConnectionClosed()
Returns true if the current database connection is closed |
boolean |
isConnectionTimeout()
Returns true if the last time this connection was used is beyond the timeout interval |
static boolean |
isLocked(DBConnection dbc)
|
static void |
main(java.lang.String[] argv)
DEBUG: Main entry point used for testing/debugging |
static boolean |
parseCommunicationsException(java.sql.SQLException sqe)
Analyze SQLException and return true if the exception refers to a communication error. |
static void |
popShowExecutedSQL()
Pops the display of SQL statements state |
static void |
pushShowExecutedSQL()
Pushes displaying SQL statement on a stack |
static void |
release(DBConnection dbc)
clear "In Use" |
static void |
release(DBConnection dbc,
java.sql.Statement stmt,
java.sql.ResultSet rs)
clear "In Use" |
static void |
setShowExecutedSQL(boolean showSQL)
Sets a flag indicating that all SQL statements should be displayed prior to execution |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean ALWAYS_NEW_CONNECTION
protected static java.util.Map<java.lang.String,DBConnection> dbConnectionMap
protected static java.util.Map<java.lang.String,java.util.ArrayList<DBConnection>> dbConnectionPool
protected static java.util.Collection<DBConnection> dbConnectionList
Constructor Detail |
---|
protected DBConnection(java.lang.String uri, java.lang.String user, java.lang.String pass)
uri
- The connection URIuser
- The user namepass
- The passwordMethod Detail |
---|
public static void setShowExecutedSQL(boolean showSQL)
showSQL
- True to display SQL statements, false otherwisepublic static boolean getShowExecutedSQL()
public static void pushShowExecutedSQL()
public static void popShowExecutedSQL()
public static boolean parseCommunicationsException(java.sql.SQLException sqe)
sqe
- The SQLException
protected static void _saveDBConnection(DBConnection dbc)
dbc
- The DBConnectionpublic static void closeAllConnections()
public static DBConnection getDBConnection(java.lang.String uri, java.lang.String user, java.lang.String pass)
uri
- The connection URIuser
- The user namepass
- The password
public static DBConnection getDefaultConnection()
public static boolean isLocked(DBConnection dbc)
public static void release(DBConnection dbc)
public static void release(DBConnection dbc, java.sql.Statement stmt, java.sql.ResultSet rs)
protected void finalize()
finalize
in class java.lang.Object
public java.lang.String getUri()
public java.lang.String getUser()
public java.lang.String getPassword()
public java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
- If an SQL error occurspublic void closeConnection()
public boolean isConnectionClosed()
public boolean isConnectionTimeout()
public java.sql.Statement createStatement() throws java.sql.SQLException
java.sql.SQLException
- If an SQL error occurspublic java.sql.Statement createStatement(boolean rowByRow) throws java.sql.SQLException
rowByRow
- True to create a new Statement in row-by-row mode
java.sql.SQLException
- If an SQL error occurspublic java.sql.Statement execute(java.lang.String sql) throws java.sql.SQLException, DBException
sql
- The String SQL statement to execute
java.sql.SQLException
- If an SQL error occurs
DBException
- If a database error occurspublic java.sql.Statement execute(java.lang.String sql, boolean rowByRow) throws java.sql.SQLException, DBException
sql
- The String SQL statement to executerowByRow
- True to create a new Statement in row-by-row mode
java.sql.SQLException
- If an SQL error occurs
DBException
- If a database error occursprotected java.sql.Statement _execute(java.lang.String sql, boolean rowByRow) throws java.sql.SQLException
sql
- The String SQL statement to executerowByRow
- True to create a new Statement in row-by-row mode
java.sql.SQLException
- If an SQL error occurs
DBException
- If a database error occurspublic java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException, DBException
sql
- The String SQL statement to execute
java.sql.SQLException
- If an SQL error occurs
DBException
- If a database error occursprotected java.sql.ResultSet _executeQuery(java.lang.String sql) throws java.sql.SQLException
sql
- The String SQL statem
java.sql.SQLException
- If an SQL error occurs
DBException
- If a database error occurspublic void executeUpdate(java.lang.String sql) throws java.sql.SQLException, DBException
sql
- The String SQL statement to execute
java.sql.SQLException
- If an SQL error occurs
DBException
- If a database error occurspublic long executeUpdate(java.lang.String sql, boolean rtnAutoIncrVal) throws java.sql.SQLException, DBException
sql
- The String SQL statement to executertnAutoIncrVal
- If auto-generated fields (ie. "auto_increment")
should be returned
java.sql.SQLException
- If an SQL error occurs
DBException
- If a database error occurspublic static void main(java.lang.String[] argv)
argv
- The command-line arguments
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |