|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cmu.survey.jsp.tags.DatabaseQuery
public class DatabaseQuery
Forms the backbone for retrieving things from the database, and has tons of database-related helper features.
It starts the connection with the database through setupConnection(), does queries through doQuery(), and retrieves the fields with getField().
There is also a large set of related parameters for formatting these in the best possible way.
and there are a large variety of helper functions for pulling and saving things in the database.
Field Summary | |
---|---|
static java.text.SimpleDateFormat |
dateFormatAmerican
|
static java.text.SimpleDateFormat |
dateTimeFormatAmerican
|
static java.text.SimpleDateFormat |
msAccessDF
|
static java.text.SimpleDateFormat |
msAccessDTF
|
static java.text.SimpleDateFormat |
msAccessTF
|
static java.text.SimpleDateFormat |
mysqlDF
Used to generate a date object from a mySQL date string |
static java.text.SimpleDateFormat |
mysqlDTF
Used to generate a date object from a mySQL date string |
static java.text.SimpleDateFormat |
mysqlTF
Used to generate a date object from a mySQL time string |
static java.text.SimpleDateFormat |
timeFormatAmerican
|
Constructor Summary | |
---|---|
DatabaseQuery(DatabaseConnection databaseConnectionToUse)
|
|
DatabaseQuery(DatabaseConnection databaseConnectionToUse,
TableStorageMySQL tableStorage)
|
|
DatabaseQuery(javax.servlet.jsp.tagext.TagSupport superclassTag)
|
Method Summary | |
---|---|
void |
clearForNextUsage()
Called for repeated usage of a DatabaseQuery. |
void |
clearLastExceptionThrown()
|
void |
close()
|
boolean |
doQuery(java.lang.String aDatabaseQuery)
Execute the current databaseQuery and leaves the results in the resultSet object. |
void |
finalize()
|
java.lang.String |
formatDateSQL(java.util.Calendar cal)
Takes a string and a format that it is in, and returns the format that SQL can understand. |
java.lang.String |
formatDateSQL(java.util.Date theDate)
Takes a string and a format that it is in, and returns the format that SQL can understand. |
java.lang.String |
formatDateTimeSQL(java.util.Calendar theDate)
Takes a Calendar and returns the format that SQL can understand. |
java.lang.String |
formatDateTimeSQL(java.util.Date theDate)
Takes a Date and returns the format that SQL can understand. |
java.lang.String |
formatDateTimeSQL(java.lang.String currentString,
java.text.DateFormat currentFormat)
Takes a string and a format that it is in, and returns the format that MySQL can understand. |
static java.lang.String |
formatDateTimeViewable(java.util.Calendar theDate)
|
static java.lang.String |
formatDateTimeViewable(java.util.Date theDate)
|
static java.lang.String |
formatDateViewable(java.util.Calendar theDate)
|
static java.lang.String |
formatDateViewable(java.util.Date theDate)
|
java.lang.String |
formatNumberSQL(int num)
|
java.lang.String |
formatNumberSQL(java.lang.Number num)
|
java.lang.String |
formatNumberSQL(java.lang.Object num)
Formats a number for the database. |
java.lang.String |
formatTimeSQL(java.util.Calendar theDate)
Takes a Calendar and returns the format that SQL can understand. |
java.lang.String |
formatTimeSQL(java.util.Date theDate)
Takes a Date returns it in a format that MySQL can understand. |
java.util.Calendar |
getCalendar()
Use the following three methods instead of making your own Date or Calendar from scratch. |
java.sql.Connection |
getDatabaseConnection()
|
java.lang.String |
getDatabaseQuery()
|
java.util.Calendar |
getDateCalendarField(java.lang.String fieldName)
|
java.util.Date |
getDateField(java.lang.String fieldName)
|
java.util.Calendar |
getDateFieldCal(java.lang.String fieldName)
|
java.util.Calendar |
getDateFrom(java.util.Calendar cale,
java.sql.Time time)
|
java.util.Calendar |
getDateFrom(java.util.Calendar cale,
java.sql.Time time,
boolean rollZerothHourToNextDay)
|
java.util.Calendar |
getDateTimeCalendarField(java.lang.String fieldName)
|
java.util.Date |
getDateTimeField(java.lang.String fieldName)
|
java.lang.String |
getField(int column)
For the current row in the resultSet, will return the value of the given field. |
java.lang.String |
getField(java.lang.String fieldName)
For the current row in the resultSet, will return the value of the given field. |
java.util.Vector<java.lang.String> |
getFields()
|
java.util.Vector<java.lang.String> |
getFields(java.lang.String fieldsToShow)
|
java.lang.Integer |
getIntegerField(java.lang.String fieldName)
|
int |
getIntField(java.lang.String fieldName)
If the database has NULL in the field, this will return 0. |
java.lang.Throwable |
getLastExceptionThrown()
|
int |
getNumRows()
|
HasErrorInfo |
getObjectWithErrorInfo()
|
java.sql.ResultSet |
getScrollableResultSet(java.lang.String aDatabaseQuery)
Execute the current databaseQuery and leaves the results in the resultSet object. |
boolean |
getSendErrorMessages()
|
java.sql.Time |
getSQLTimeField(java.lang.String fieldName)
|
DatabaseConnection |
getTheConnection()
|
java.sql.Time |
getTimeField(java.lang.String fieldName)
|
java.util.Calendar |
getTimeFieldCal(java.lang.String fieldName)
|
java.sql.Timestamp |
getTimestampField(java.lang.String fieldName)
|
java.util.TimeZone |
getTimeZone()
|
java.sql.ResultSet |
getUnscrollableResultSet(java.lang.String aDatabaseQuery)
Execute the current databaseQuery and leaves the results in the resultSet object. |
boolean |
isDatabaseOpen()
|
boolean |
moveToNextRecord()
|
java.util.Calendar |
parseDateCalendarFromSQL(java.lang.String dateTime)
Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand. |
java.util.Date |
parseDateFromSQL(java.lang.String time)
Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand. |
static java.util.Calendar |
parseDateTimeCalendarFromAnyFormat(java.lang.String dateTime)
Takes a String in the default database format and parses it into a Calendar. |
java.util.Calendar |
parseDateTimeCalendarFromSQL(java.lang.String dateTime)
Takes a String in the default database format and parses it into a Calendar. |
static java.util.Date |
parseDateTimeFromAnyFormat(java.lang.String dateTime)
Takes a String in the default database format and parses it into a Date. |
java.util.Date |
parseDateTimeFromSQL(java.lang.String dateTime)
Takes a String in the default database format and parses it into a Date. |
java.util.Date |
parseDateTimeFromSQL(java.lang.String date,
java.lang.String time)
Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand. |
java.util.Date |
parseTimeFromSQL(java.lang.String time)
Takes a String in the default database format and parses it into a Date and returns the format that MySQL can understand. |
void |
resetFieldsForNextRecord()
Nulls out the hash table containing the row from the recordset |
protected void |
saveErrorMessage(java.lang.String error)
|
protected void |
saveErrorMessage(java.lang.String error,
java.lang.Throwable e)
|
protected void |
saveErrorMessage(java.lang.Throwable e)
|
void |
setDatabaseQuery(java.lang.String value)
|
void |
setObjectWithErrorInfo(HasErrorInfo info)
|
void |
setSendErrorMessages(boolean emailTheErrorMessages)
|
void |
setTimeZone(java.util.TimeZone zone)
|
void |
setupConnection()
|
void |
setupConnection(DatabaseConnection theNewConnection)
Used to initialize the connection object, statements, and JSPWriter (out). |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.text.SimpleDateFormat mysqlTF
public static final java.text.SimpleDateFormat mysqlDF
public static final java.text.SimpleDateFormat mysqlDTF
public static final java.text.SimpleDateFormat msAccessDTF
public static final java.text.SimpleDateFormat msAccessDF
public static final java.text.SimpleDateFormat msAccessTF
public static final java.text.SimpleDateFormat dateFormatAmerican
public static final java.text.SimpleDateFormat dateTimeFormatAmerican
public static final java.text.SimpleDateFormat timeFormatAmerican
Constructor Detail |
---|
public DatabaseQuery(DatabaseConnection databaseConnectionToUse)
public DatabaseQuery(DatabaseConnection databaseConnectionToUse, TableStorageMySQL tableStorage)
public DatabaseQuery(javax.servlet.jsp.tagext.TagSupport superclassTag)
Method Detail |
---|
public void setSendErrorMessages(boolean emailTheErrorMessages)
public boolean getSendErrorMessages()
protected void saveErrorMessage(java.lang.Throwable e)
protected void saveErrorMessage(java.lang.String error, java.lang.Throwable e)
protected void saveErrorMessage(java.lang.String error)
public java.lang.Throwable getLastExceptionThrown()
public void clearLastExceptionThrown()
public java.lang.String formatDateSQL(java.util.Date theDate)
public java.lang.String formatDateSQL(java.util.Calendar cal)
public java.lang.String formatTimeSQL(java.util.Date theDate)
public java.lang.String formatDateTimeSQL(java.util.Date theDate)
public java.lang.String formatDateTimeSQL(java.util.Calendar theDate)
public java.lang.String formatTimeSQL(java.util.Calendar theDate)
public java.lang.String formatNumberSQL(java.lang.Number num)
public java.lang.String formatNumberSQL(int num)
public java.lang.String formatNumberSQL(java.lang.Object num)
public java.lang.String formatDateTimeSQL(java.lang.String currentString, java.text.DateFormat currentFormat)
public static java.lang.String formatDateTimeViewable(java.util.Calendar theDate)
public static java.lang.String formatDateTimeViewable(java.util.Date theDate)
public static java.lang.String formatDateViewable(java.util.Calendar theDate)
public static java.lang.String formatDateViewable(java.util.Date theDate)
public java.util.Date parseDateTimeFromSQL(java.lang.String dateTime)
public static java.util.Date parseDateTimeFromAnyFormat(java.lang.String dateTime)
public java.util.Calendar parseDateTimeCalendarFromSQL(java.lang.String dateTime)
public static java.util.Calendar parseDateTimeCalendarFromAnyFormat(java.lang.String dateTime)
public java.util.Calendar parseDateCalendarFromSQL(java.lang.String dateTime)
public java.util.Date parseDateTimeFromSQL(java.lang.String date, java.lang.String time)
public java.util.Date parseDateFromSQL(java.lang.String time)
public java.util.Date parseTimeFromSQL(java.lang.String time)
public java.util.Calendar getDateFrom(java.util.Calendar cale, java.sql.Time time, boolean rollZerothHourToNextDay)
public java.util.Calendar getDateFrom(java.util.Calendar cale, java.sql.Time time)
public java.util.Calendar getCalendar()
public void setupConnection(DatabaseConnection theNewConnection)
public void setupConnection()
public boolean doQuery(java.lang.String aDatabaseQuery)
public java.sql.ResultSet getScrollableResultSet(java.lang.String aDatabaseQuery)
public java.sql.ResultSet getUnscrollableResultSet(java.lang.String aDatabaseQuery)
public java.util.Date getDateTimeField(java.lang.String fieldName)
public java.util.Calendar getDateCalendarField(java.lang.String fieldName)
public java.util.Calendar getDateTimeCalendarField(java.lang.String fieldName)
public java.sql.Time getTimeField(java.lang.String fieldName)
public java.sql.Time getSQLTimeField(java.lang.String fieldName)
public java.util.Date getDateField(java.lang.String fieldName)
public java.util.Calendar getTimeFieldCal(java.lang.String fieldName)
public java.util.Calendar getDateFieldCal(java.lang.String fieldName)
public java.sql.Timestamp getTimestampField(java.lang.String fieldName)
public int getIntField(java.lang.String fieldName)
fieldName
-
public java.lang.Integer getIntegerField(java.lang.String fieldName)
public java.lang.String getField(java.lang.String fieldName)
fieldName
- The attribute who's value you want
public java.lang.String getField(int column)
column
- the column ID
public void resetFieldsForNextRecord()
public boolean moveToNextRecord()
public java.util.Vector<java.lang.String> getFields()
public int getNumRows()
public java.util.Vector<java.lang.String> getFields(java.lang.String fieldsToShow)
public void close()
public void finalize()
finalize
in class java.lang.Object
public boolean isDatabaseOpen()
public void setDatabaseQuery(java.lang.String value)
public java.lang.String getDatabaseQuery()
public java.sql.Connection getDatabaseConnection()
public DatabaseConnection getTheConnection()
public HasErrorInfo getObjectWithErrorInfo()
public void setObjectWithErrorInfo(HasErrorInfo info)
info
- public java.util.TimeZone getTimeZone()
public void setTimeZone(java.util.TimeZone zone)
zone
- public void clearForNextUsage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |