|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--util.sql.SQLProcessor
Main class for performing all SQL operations, querying, updating, transactions etc... The main goal of this class is to take away the redundancy and overhead that occurs with each SQL query/update. The only variability in each SQL operation is:
All other functionality, including getting a connection, entering values into a prepared statement, exception handling etc... should factored out. That's just what this class does.
Method Summary | |
void |
closeConn(java.sql.Connection conn)
Close the connection, can handle null connections. |
java.lang.Object[] |
executeQuery(java.lang.String sql,
java.lang.Object[] pStmntValues,
ResultProcessor processor)
Start the execution of SQL query. |
void |
executeUpdate(java.lang.String sql,
java.lang.Object[] pStmntValues,
UpdateProcessor processor)
Execute an update and setup and destroy the connection associate with it. |
static SQLProcessor |
getInstance()
Get an instance of a SQLProcessor. |
protected java.lang.Object[] |
handleQuery(java.lang.String sql,
java.lang.Object[] pStmntValues,
ResultProcessor processor,
java.sql.Connection conn)
Method that handles the bulk of the query processing. |
protected void |
handleUpdate(java.lang.String sql,
java.lang.Object[] pStmntValues,
UpdateProcessor processor,
java.sql.Connection conn)
Method that handles the bulk of the update processing. |
SQLTransaction |
startTransaction()
Start a transaction. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static SQLProcessor getInstance()
public java.lang.Object[] executeQuery(java.lang.String sql, java.lang.Object[] pStmntValues, ResultProcessor processor)
sql
- the sql query string to executepStmntValues
- the values to enter into the prepared statement. If there are no values, use
null
processor
- the result processor that will handle the result set produced by this query. This is what
will ultimately decide what return value is handed back.protected java.lang.Object[] handleQuery(java.lang.String sql, java.lang.Object[] pStmntValues, ResultProcessor processor, java.sql.Connection conn)
Note: This method does not close the connection. This is left up to the calling method as it is what supplied the connection. If all handling of the connections is desired, use the executeQuery method! (However, in the case of any exceptions, the connection will closed)
sql
- the sql query string to executepStmntValues
- the values to enter into the prepared statement. If there are no values, use
null
processor
- the result processor that will handle the result set produced by this query. This is what
will ultimately decide what return value is handed back.conn
- the connection to use when getting a prepared statementDatabaseQueryException
- public void executeUpdate(java.lang.String sql, java.lang.Object[] pStmntValues, UpdateProcessor processor)
sql
- the sql query string to executepStmntValues
- the values to enter into the prepared statement. If there are no values, use null
processor
- the result processor that will handle the result set produced by this query. This is what
will ultimately decide what return value is handed back.appId
- the app id of the application that's calling this method. Used to get an app specific
connection.protected void handleUpdate(java.lang.String sql, java.lang.Object[] pStmntValues, UpdateProcessor processor, java.sql.Connection conn)
Note: This method does not close the connection by default. This is left up to the calling method as it is what supplied the connection. It will only be closed in the case of an exception.
sql
- the sql update string to executepStmntValues
- the values to enter into the prepared statement. If there are no values, use null
processor
- conn
- public void closeConn(java.sql.Connection conn)
conn
- the connection to closepublic SQLTransaction startTransaction()
appId
- the app id to use when determining the connection's permissions
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |