|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.jhu.tmaj.database.DatabaseUtil
public final class DatabaseUtil
Contains various functions used to modify the database (UPDATE, INSERT, and DELETE statements) and to query the database (very simple SELECT statements). For general use of SELECT statements, use the AbstractDatabaseQuery class.
Constructor Summary | |
---|---|
DatabaseUtil()
|
|
DatabaseUtil(DatabaseLink databaseLink)
Constructs this object. |
Method Summary | |
---|---|
void |
deleteSingleRecord(DeleteSQL sql)
|
int |
doDelete(DeleteSQL sql)
Handles a single update SQL statement, and returns the number of rows updated |
int |
doInsert(InsertSQL insertSQL)
Inserts a row into the database given a SQL statement and returns the ID assigned. |
void |
doModifies(java.util.List<? extends ModifySQL> modifingSQLList)
|
void |
doModifies(java.util.List<? extends ModifySQL> modifingSQLList,
java.lang.String description)
Executes a List of Modifying SQL statements. |
int |
doUpdate(UpdateSQL updateSQL)
Handles a single update SQL statement, and returns the number of rows updated |
static DatabaseUtil |
getInstance()
|
java.util.List<java.lang.Integer> |
getIntegerList(java.lang.String sql,
java.lang.String columnName)
Returns a List of Integers generated by a SQL statement. |
java.lang.Integer |
getSQLInteger(java.lang.String sql,
java.lang.String columnName)
Queries the database for the Integer of the first row in the specified column, given a SQL query. |
java.lang.String |
getSQLString(java.lang.String sql,
java.lang.String columnName)
|
java.util.List<java.lang.String> |
getStringList(java.lang.String sql,
java.lang.String columnName)
Returns a List of Strings generated by a SQL statement. |
void |
updateSingleRecord(UpdateSQL sql)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DatabaseUtil(DatabaseLink databaseLink)
connectionManager
- the connection manager that will give us our connection to the databasesqlMaker
- the sql maker that will convert SQL objects to text sqlpublic DatabaseUtil()
Method Detail |
---|
public static DatabaseUtil getInstance()
public int doInsert(InsertSQL insertSQL) throws java.sql.SQLException
java.sql.SQLException
public int doUpdate(UpdateSQL updateSQL) throws java.sql.SQLException
java.sql.SQLException
public int doDelete(DeleteSQL sql) throws java.sql.SQLException
java.sql.SQLException
public void doModifies(java.util.List<? extends ModifySQL> modifingSQLList, java.lang.String description) throws java.sql.SQLException
modifingSQLList
- a List of UpdateSQL,InsertSQL, and DeleteSQL objectsprogressMonitor
- an optional TextProgressMonitordoNotLogSQL
- true if you do not want this sql logged. You might want to set this to true if
there is just an incredible amount of sql that would slow this operation down, or
the sql contained sensitive information.
java.sql.SQLException
public void doModifies(java.util.List<? extends ModifySQL> modifingSQLList) throws java.sql.SQLException
java.sql.SQLException
public void updateSingleRecord(UpdateSQL sql) throws java.sql.SQLException
java.sql.SQLException
public void deleteSingleRecord(DeleteSQL sql) throws java.sql.SQLException
java.sql.SQLException
public java.lang.Integer getSQLInteger(java.lang.String sql, java.lang.String columnName) throws java.sql.SQLException
sql
- a SQL SELECT statement returning one row. For example, "SELECT COUNT(*) AS
My_Count"columnName
- the column name to be retrieved, who type is numeric. For example "My_Count"
java.lang.RuntimeException
- if more than 1 row is returned
java.sql.SQLException
public java.lang.String getSQLString(java.lang.String sql, java.lang.String columnName) throws java.sql.SQLException
java.sql.SQLException
public java.util.List<java.lang.Integer> getIntegerList(java.lang.String sql, java.lang.String columnName) throws java.sql.SQLException
sql
- the sql, example: SELECT EmployeeID FROM EmployeescolumnName
- the name of the column to get. Example: "EmployeeID"
java.sql.SQLException
public java.util.List<java.lang.String> getStringList(java.lang.String sql, java.lang.String columnName) throws java.sql.SQLException
sql
- the sql, example: SELECT EmployeeName FROM EmployeescolumnName
- the name of the column to get. Example: "EmployeeName"
java.sql.SQLException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |