|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--kiurubeans.SimpleDb
Facilitates executing simple ad hoc queries using kotkabeans.DB.
Constructor Summary | |
SimpleDb()
Creates new SimpleDb |
Method Summary | |
static java.lang.String |
addSqlDeleted(StringPair[] tables)
Returns "deleted" part in where clause. |
static java.lang.String |
addSqlFrom(StringPair[] tables)
returns "from" part of SQL |
static boolean |
checkIfEditable(RS2 rs)
Checks if user can edit current record & moves RS cursor to first record This should be called after every query before properties are assigned to bean. |
static boolean |
executeTransaction(java.util.ArrayList a,
java.lang.String dbLog)
Like ExecuteTransaction(Statementcontainer[],String), but takes list instead of array. |
static boolean |
executeTransaction(StatementContainer[] sc,
java.lang.String dbLog)
Executes array of prepared statements in a transaction. |
static boolean |
executeTransaction(StatementContainer[] sc,
java.lang.String dbLog,
DB db)
Executes array of prepared statements in a transaction. |
static java.lang.String |
formatOrSet(java.lang.String fieldname,
java.lang.String[] ids)
Formats SQL search string from array of id numbers. |
static java.lang.String |
formatSearchString(java.lang.String fieldName,
java.lang.String searchStr)
Formats SQL search string from user's input. |
static java.lang.String |
formatSearchString(java.lang.String fieldName,
java.lang.String searchStr,
boolean beginAnd)
Formats SQL search string from user's input. |
static java.lang.String |
getDateTimeString(RS2 rs,
java.lang.String column)
Returns value of a timestamp field in compact notation. |
static java.lang.String |
getString(RS2 rs,
java.lang.String column)
Filters off 'null' result strings from RS2.getString |
static java.lang.String |
getString(RS2 rs,
java.lang.String[] column)
Filters off 'null' result strings from RS2.getString and combines them with space as delimiter |
static boolean |
isEmpty(RS2 rs)
Tests if rs2 is NULL or empty. |
static boolean |
recordExists(DB db,
java.lang.String table,
java.lang.String idname,
int idvalue)
Checks if record exists of the given table. |
static boolean |
recordExists(DB db,
java.lang.String table,
StringPair[] values)
Checks if record exists of the given table. |
static java.lang.String[] |
RS2toArray(RS2 rs,
java.lang.String colname)
Converts given column in RS2 to string array |
static RS2 |
simpleQuery(java.lang.String logstring,
java.lang.String querystring)
Executes simple database query. |
static int |
simpleUpdate(java.lang.String logstring,
java.lang.String updatestring)
Executes simple database update. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SimpleDb()
Method Detail |
public static java.lang.String[] RS2toArray(RS2 rs, java.lang.String colname) throws java.lang.Exception
rs
- RS2 containing recordscolname
- Column name where we fetch values from
String[]
-array containing all values from column
colname
.
java.lang.Exception
- Something went wrong when handling RS2public static RS2 simpleQuery(java.lang.String logstring, java.lang.String querystring) throws java.lang.Exception
logstring
- Information for logging purposes.querystring
- Actual query.
java.lang.Exception
- Database query couldn't made successfully.public static int simpleUpdate(java.lang.String logstring, java.lang.String updatestring) throws java.lang.Exception
logstring
- Information for logging purposes.updatestring
- Actual update sql clause.
java.lang.Exception
- Database query couldn't made successfully.public static boolean recordExists(DB db, java.lang.String table, java.lang.String idname, int idvalue) throws java.lang.Exception
db
- Open database connectiontable
- Name of the table we are looking at.idname
- Column name of the primary key.idvalue
- Value of the primary key.
java.lang.Exception
- Something illegal happened during database query.public static boolean recordExists(DB db, java.lang.String table, StringPair[] values) throws java.lang.Exception
db
- Open database connectiontable
- Name of the table we are looking at.values
- array of StringPair containing column names and values
java.lang.Exception
- Something illegal happened during database query.public static boolean executeTransaction(java.util.ArrayList a, java.lang.String dbLog)
a
- Arraylist containing StatementContainers.dbLog
- Log string
public static boolean executeTransaction(StatementContainer[] sc, java.lang.String dbLog)
sc
- StatementContainer containing database statementsdbLog
- Log string
public static boolean executeTransaction(StatementContainer[] sc, java.lang.String dbLog, DB db)
sc
- StatementContainer containing database statementsdbLog
- Log stringdb
- Open database connection
public static boolean checkIfEditable(RS2 rs) throws java.lang.Exception
rs
- RS2
java.lang.Exception
- Something illegal happened during database operations.public static java.lang.String getString(RS2 rs, java.lang.String column) throws java.lang.Exception
rs
- RS2 containing resultscolumn
- Which column we are interested in
column
or '-' if it is null
java.lang.Exception
- Something illegal happened during database operationspublic static java.lang.String getDateTimeString(RS2 rs, java.lang.String column) throws java.lang.Exception
rs
- current resultsetcolumn
- column in resultset (should be of type timestamp)
java.lang.Exception
- Something illegal happened during database operations.public static java.lang.String getString(RS2 rs, java.lang.String[] column) throws java.lang.Exception
rs
- RS2 containing resultscolumn
- Column names of the columns we are interested in.
Null
s are replaced
with '-'
s.
java.lang.Exception
- Something illegal happened during database operations.public static java.lang.String formatSearchString(java.lang.String fieldName, java.lang.String searchStr)
fieldName
- Field name the user is searching.searchStr
- Search string
public static java.lang.String formatSearchString(java.lang.String fieldName, java.lang.String searchStr, boolean beginAnd)
fieldName
- Field name the user is searching.searchStr
- Search stringbeginAnd
- Do we begin our search string with 'and'
public static java.lang.String formatOrSet(java.lang.String fieldname, java.lang.String[] ids)
fieldname
- The name of the column we are searchingids
- ids of the records we are looking for.
public static java.lang.String addSqlFrom(StringPair[] tables)
tables
- table names (and aliases) in stringpair array. assumes key is alias, content tablename
public static java.lang.String addSqlDeleted(StringPair[] tables)
tables
- table names (and aliases) in stringpair array. key is used in clause
public static boolean isEmpty(RS2 rs)
rs
- RS2 we are testing
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |