|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensubsystems.core.util.DatabaseUtils
public final class DatabaseUtils
Set of common utility methods related to database access.
| Field Summary | |
|---|---|
protected static java.util.Map |
s_mpDependencyCache
Hashed tables-columns existance information for dependency checking. |
| Method Summary | |
|---|---|
static void |
closeResultSet(java.sql.ResultSet results)
Gracefully close result set so that no error is generated. |
static void |
closeResultSetAndStatement(java.sql.ResultSet results,
java.sql.Statement jdbcstatement)
Gracefully close result set and statement so that no error is generated. |
static void |
closeStatement(java.sql.Statement jdbcstatement)
Gracefully close statement so that no error is generated. |
protected static int |
estimateResultSetSize(java.sql.ResultSet rsQueryResults)
Estimate the size of the result set so that data structures can be allocated efficiently. |
static int |
executeUpdateAndClose(java.sql.PreparedStatement jdbcstatement)
Execute given statement and close the statement after it is done. |
static java.util.List |
getInListWithSafeLength(java.util.Collection idList,
boolean bQuote)
Because there is limitation for sql statement length (in sap db is default 64 kb) and in() expression can contain lot of members, this function will construct list of strings with maximum number of allowed members (representing ids) each. |
static boolean |
hasRelations(java.lang.String[][] arTableColumn,
int iId)
This method is for relation checking and for hashing table-column existance for optimalization. |
static DataObject |
loadAtMostOneData(DatabaseFactory factory,
java.sql.PreparedStatement pstmQuery,
java.lang.String strErrorMessage)
Execute statement and load at most one data object from the result set and if the result set contains more than one item announce error. |
static int |
loadAtMostOneInt(java.sql.PreparedStatement pstmQuery,
int iDefault,
java.lang.String strErrorMessage)
Execute statement and load at most one data object from the result set and if the result set contains more than one item announce error. |
static java.lang.String |
loadAtMostOneString(java.sql.PreparedStatement pstmQuery,
java.lang.String strDefault,
java.lang.String strErrorMessage)
Execute statement and load at most one data object from the result set and if the result set contains more than one item announce error. |
static java.util.List |
loadMultipleData(DatabaseFactory factory,
java.sql.PreparedStatement pstmQuery)
Execute statement and load multiple data objects from the result set. |
static java.util.Set |
loadMultipleDataToSet(DatabaseFactory factory,
java.sql.PreparedStatement pstmQuery,
boolean bLoadSpecific)
Execute statement and load multiple data objects from the result set. |
static int[] |
loadMultipleIntsAsArray(java.sql.PreparedStatement pstmQuery)
Execute statement and load multiple int's from the result set. |
static java.util.List |
loadMultipleStrings(java.sql.PreparedStatement pstmQuery)
Execute statement and load multiple strings from the result set. |
static TwoIntStruct[] |
loadMultipleTwoIntStruct(java.sql.PreparedStatement pstmQuery)
Execute statement and load multiple TwoIntStruct objects from the result set. |
static int[] |
mergeColumnsSafely(int[] arrOriginalColumns,
int[] arrExtraColumns)
Merge new columns to the list of existing columns safely so if they already exist in the original list, they won't be added. |
static void |
rollbackAndIgnoreException(java.sql.Connection cntConnection)
Rollback transaction and ingore any exception if it occurs. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static java.util.Map s_mpDependencyCache
| Method Detail |
|---|
public static int executeUpdateAndClose(java.sql.PreparedStatement jdbcstatement)
throws java.sql.SQLException
jdbcstatement - - statement to execute
java.sql.SQLException - - only if the update fails, not in any other casepublic static void closeResultSet(java.sql.ResultSet results)
results - - result set to close, if null it is ignored
public static void closeResultSetAndStatement(java.sql.ResultSet results,
java.sql.Statement jdbcstatement)
results - - result set to close, if null it is ignoredjdbcstatement - - jdbc statement to close, if null it is ignoredpublic static void closeStatement(java.sql.Statement jdbcstatement)
jdbcstatement - - jdbc statement to close, if null it is ignored
public static DataObject loadAtMostOneData(DatabaseFactory factory,
java.sql.PreparedStatement pstmQuery,
java.lang.String strErrorMessage)
throws java.sql.SQLException,
OSSException
factory - - factory used to load datapstmQuery - - query to executestrErrorMessage - - error message to announce if there is more than
one item
java.sql.SQLException - - an error has occured
OSSException - - an error has occured
public static int loadAtMostOneInt(java.sql.PreparedStatement pstmQuery,
int iDefault,
java.lang.String strErrorMessage)
throws java.sql.SQLException,
OSSException
pstmQuery - - query to executeiDefault - - default value to return if the result set doesn't contain
any valuestrErrorMessage - - error message to announce if there is more than
one item
java.sql.SQLException - - an error has occured
OSSException - - an error has occured
public static java.lang.String loadAtMostOneString(java.sql.PreparedStatement pstmQuery,
java.lang.String strDefault,
java.lang.String strErrorMessage)
throws java.sql.SQLException,
OSSException
pstmQuery - - query to executestrDefault - - default value to return if the result set doesn't contain
any valuestrErrorMessage - - error message to announce if there is more than
one item
java.sql.SQLException - - an error has occured
OSSException - - an error has occured
public static java.util.List loadMultipleData(DatabaseFactory factory,
java.sql.PreparedStatement pstmQuery)
throws java.sql.SQLException,
OSSException
factory - - factory used to load datapstmQuery - - query to execute
java.sql.SQLException - - an error has occured
OSSException - - an error has occured
public static java.util.Set loadMultipleDataToSet(DatabaseFactory factory,
java.sql.PreparedStatement pstmQuery,
boolean bLoadSpecific)
throws java.sql.SQLException,
OSSException
factory - - factory used to load datapstmQuery - - query to executebLoadSpecific - - flag signaling if there will be loaded specific data
false ... all columns will be loaded from resultset
and set up whole object to the HashSet
true ... 1st column will be loaded from resultset
and set up only particular data to the HashSet
java.sql.SQLException - - an error has occured
OSSException - - an error has occured
public static java.util.List loadMultipleStrings(java.sql.PreparedStatement pstmQuery)
throws java.sql.SQLException,
OSSException
pstmQuery - - query to execute
java.sql.SQLException - - an error has occured
OSSException - - an error has occured
public static int[] loadMultipleIntsAsArray(java.sql.PreparedStatement pstmQuery)
throws java.sql.SQLException,
OSSException
pstmQuery - - query to execute
java.sql.SQLException - - an error has occured
OSSException - - an error has occured
public static TwoIntStruct[] loadMultipleTwoIntStruct(java.sql.PreparedStatement pstmQuery)
throws java.sql.SQLException,
OSSException
pstmQuery - - query to execute
java.sql.SQLException - - an error has occured
OSSException - - an error has occured
public static boolean hasRelations(java.lang.String[][] arTableColumn,
int iId)
throws OSSException
arTableColumn - - array of {table name, column name} arrays to check
relation toiId - - id of the object to check relations
OSSException - - error during checkpublic static void rollbackAndIgnoreException(java.sql.Connection cntConnection)
cntConnection - - connection to rollback if necessary
public static int[] mergeColumnsSafely(int[] arrOriginalColumns,
int[] arrExtraColumns)
arrOriginalColumns - - list of original columnsarrExtraColumns - - new columns to add to the list
public static java.util.List getInListWithSafeLength(java.util.Collection idList,
boolean bQuote)
idList - - collection with ids (as Objects)bQuote - - flag signaling if there will be used quotes when
string items will be served
- true = there will be used quotes; false = otherwise
protected static int estimateResultSetSize(java.sql.ResultSet rsQueryResults)
throws java.sql.SQLException,
OSSException
rsQueryResults - - resultset of size of which to estimate
java.sql.SQLException - - an error has occured
OSSException - - an error has occured
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||