public class Utility extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Connection |
dbConnection
Represents the connection object that is used by the class to execute SQL
statements
|
static int |
ERR_CATEGORY_CONNECTION |
static int |
ERR_CATEGORY_SQL |
static int |
ERR_CATEGORY_STORED_PROCEDURES_ERROR |
static int |
ERR_CATEGORY_STORED_PROCEDURES_RECOMPILED |
static int |
EXCEPTION_CONNECTION_RESET |
static int |
EXCEPTION_CONNECTION_SHUT |
protected DBErrorHandler |
handler
Handles the errors regarding this connection
|
protected DBIOHandler |
ioHandler |
protected DBConnection |
smyldDbConnection |
| Constructor and Description |
|---|
Utility(DBConnection activeDBConnection,
DBErrorHandler e)
Constructs the class with the given connection object to be used for the
execution of statements
|
| Modifier and Type | Method and Description |
|---|---|
void |
closeCursor(PreparedStatement stRecords)
Close the cursor opened through the given prepared statement object
|
void |
closeCursor(ResultSet rsRecords)
Close the cursor opened through the given result set object
|
static String |
constructDoubleParamFunctionCall(String functionName) |
static String |
constructDoubleParamProcedureCall(String ProcedureName) |
static String |
constructMultiParamFunctionCall(String functionName,
int paramsNo) |
static String |
constructMultiParamProcedureCall(String ProcedureName,
int paramsNo) |
static String |
constructSingleParamFunctionCall(String functionName) |
static String |
constructSingleParamProcedureCall(String ProcedureName) |
static String |
constructTrippleParamFunctionCall(String functionName) |
static String |
constructTrippleParamProcedureCall(String ProcedureName) |
String |
createInsertSQL(String tableName) |
String |
detectLongFieldError(PreparedStatement st) |
boolean |
doDoubleParamSQL(String firstParam,
String secondParam,
String sqlText)
To invoke the given sql and set the given 2 parameters using execute
method
|
int |
doDoubleParamUpdateSQL(String firstParam,
String secondParam,
String sqlText)
To invoke the given sql and set the given 2 parameters using
executeUpdate method
|
int |
doQuadParamUpdateSQL(String firstParam,
String secondParam,
String thirdParam,
String fourthParam,
String sqlText)
To invoke the given sql and set the given 3 parameters using
executeUpdate method
|
boolean |
doSingleParamSQL(int firstParam,
String sqlText)
To invoke the given sql and set the given integer parameter using execute
method
|
boolean |
doSingleParamSQL(String firstParam,
String sqlText)
To invoke the given sql and set the given string parameter using execute
method
|
int |
doSingleParamUpdateSQL(String firstParam,
String sqlText)
To invoke the given sql and set the given string parameter using
executeUpdate method and returns the affected records number
|
int |
doTrippleParamUpdateSQL(String firstParam,
String secondParam,
String thirdParam,
String sqlText)
To invoke the given sql and set the given 3 parameters using
executeUpdate method
|
void |
executeDoubleParamFunction(String function,
int param1,
int param2) |
void |
executeDoubleParamFunction(String function,
String param1,
String param2) |
void |
executeDoubleParamProcedure(String procedure,
int param1,
int param2) |
void |
executeDoubleParamProcedure(String procedure,
String param1,
String param2) |
void |
executeMultiParamProcedure(String procedure,
String[] params) |
ResultSet |
executeQuery(String sqlText)
To invoke the given sql using executeQuery method
|
void |
executeTrippleParamFunction(String function,
String param1,
String param2,
String param3) |
void |
executeTrippleParamProcedure(String procedure,
String param1,
int param2,
int param3) |
ResultSet |
fetchTableData(String tableName)
Fetches the all the records of the given table with out any conditions
|
HashMap<String,Field> |
FetchTableFields(String TableName,
String FieldName,
String FieldValue)
Fetchs the given table name data and returns HashMap object containing
org.smyld.db.Field objects created upon the given field Name/Value pair
(represents 2 column names in the given table name)
|
void |
FillColumnNames(ResultSetMetaData rsMetaData,
HashMap<String,Integer> results) |
Connection |
getConnection() |
int |
getCount(ResultSet rs) |
ResultSet |
getDoubleParamSQL(int firstParam,
int secondParam,
String sqlText)
To invoke the given sql using executeQuery method,setting the given 2
parameter and returning the resultant result set
|
ResultSet |
getDoubleParamSQL(int firstParam,
String secondParam,
String sqlText)
To invoke the given sql using executeQuery method,setting the given 2
parameter and returning the resultant result set
|
ResultSet |
getDoubleParamSQL(String firstParam,
String secondParam,
String sqlText)
To invoke the given sql using executeQuery method,setting the given 2
parameter and returning the resultant result set
|
static int |
getErrorCategory(Exception ex) |
protected static String |
getParamsText(int paramsNo) |
ResultSet |
getQuadParamSQL(String firstParam,
String secondParam,
String thirdParam,
String fourthParam,
String sqlText) |
int |
getSequenceValue(String seqName) |
int |
getSequentialID(String tableName,
String idColName)
Calculate the value of the given column name in the given table and
increase it by one.
|
int |
getSequentialID(String tableName,
String idColName,
String whereColumnName,
String whereColumnValue)
Calculate the value of the given column name in the given table and
increase it by one.
|
ResultSet |
getSingleParamSQL(String paramValue,
String sqlText)
To invoke the given sql using executeQuery method,setting the given
parameter and returning the resultant result set
|
String |
getSingleParamSQLData(String firstParam,
String sqlText,
String columnName)
To invoke the given sql using class getSingleParamSQL method,setting the
given parameter and returning the gievn column name value
|
String |
getSQLData(String sqlText,
String columnName)
To invoke the given sql using class executeQuery method, and returning
the gievn column name value
|
ResultSet |
getSQLResultSet(String sqlText) |
static String |
getStringIndex(int digitWidth,
int index)
Returns the index represented as the required number of digit text.
|
Vector<TableColumn> |
getTableCols(String tableName) |
ResultSet |
getTrippleParamSQL(int firstParam,
int secondParam,
String thirdParam,
String sqlText)
To invoke the given sql and set the given 3 parameters using executeQuery
method and returns the resultant result set
|
ResultSet |
getTrippleParamSQL(String firstParam,
String secondParam,
String thirdParam,
String sqlText)
To invoke the given sql and set the given 3 parameters using executeQuery
method and returns the resultant result set
|
void |
handleDBError(Exception ex) |
void |
importFile(String targetTable,
String fileName) |
boolean |
isDoubleExist(String firstParam,
String secondParam,
String sqlText)
Checking if the given double parameter sql statement contains records or
not
|
boolean |
isExist(ResultSet rsRecords)
Checking if the given result set contains records or not
|
boolean |
isExist(String sqlText)
Checking if the given single parameter sql statement contains records or
not
|
boolean |
isSingleExist(String firstParam,
String sqlText)
Checking if the given single parameter sql statement contains records or
not
|
boolean |
isTrippleExist(String firstParam,
String secondParam,
String thirdParam,
String sqlText)
Checking if the given tripple parameter sql statement contains records or
not
|
void |
setSMYLDConnection(DBConnection activeConnection) |
protected Connection dbConnection
protected DBConnection smyldDbConnection
protected DBIOHandler ioHandler
protected DBErrorHandler handler
public static final int ERR_CATEGORY_SQL
public static final int ERR_CATEGORY_CONNECTION
public static final int ERR_CATEGORY_STORED_PROCEDURES_RECOMPILED
public static final int ERR_CATEGORY_STORED_PROCEDURES_ERROR
public static final int EXCEPTION_CONNECTION_RESET
public static final int EXCEPTION_CONNECTION_SHUT
public Utility(DBConnection activeDBConnection, DBErrorHandler e)
activeConnection - the active data base connection objecte - the error handler object that takes care of the errors raised
during this connectionpublic void closeCursor(ResultSet rsRecords)
rsRecords - the result set of the opened cursorpublic void closeCursor(PreparedStatement stRecords)
stRecords - the prepared statement of the opened cursorpublic boolean doDoubleParamSQL(String firstParam, String secondParam, String sqlText)
firstParam - the first parameter valuesecondParam - the second parameter valuesqlText - the SQL statementpublic void setSMYLDConnection(DBConnection activeConnection)
public int doDoubleParamUpdateSQL(String firstParam, String secondParam, String sqlText)
firstParam - the first parameter valuesecondParam - the second parameter valuesqlText - the SQL statementpublic boolean doSingleParamSQL(int firstParam,
String sqlText)
firstParam - the first parameter valuesqlText - the SQL statementpublic String detectLongFieldError(PreparedStatement st) throws SQLException
SQLExceptionpublic int doTrippleParamUpdateSQL(String firstParam, String secondParam, String thirdParam, String sqlText)
firstParam - the first parameter valuesecondParam - the second parameter valuethirdParam - the third parameter valuesqlText - the SQL statementpublic int doQuadParamUpdateSQL(String firstParam, String secondParam, String thirdParam, String fourthParam, String sqlText)
firstParam - the first parameter valuesecondParam - the second parameter valuethirdParam - the third parameter valuesqlText - the SQL statementpublic ResultSet getTrippleParamSQL(String firstParam, String secondParam, String thirdParam, String sqlText)
firstParam - the first parameter valuesecondParam - the second parameter valuethirdParam - the third parameter valuesqlText - the SQL statementpublic ResultSet getQuadParamSQL(String firstParam, String secondParam, String thirdParam, String fourthParam, String sqlText)
public ResultSet getTrippleParamSQL(int firstParam, int secondParam, String thirdParam, String sqlText)
firstParam - the first parameter valuesecondParam - the second parameter valuethirdParam - the third parameter valuesqlText - the SQL statementpublic int doSingleParamUpdateSQL(String firstParam, String sqlText)
firstParam - the first parameter valuesqlText - the SQL statementpublic boolean doSingleParamSQL(String firstParam, String sqlText)
firstParam - the first parameter valuesqlText - the SQL statementpublic ResultSet executeQuery(String sqlText)
sqlText - the SQL statementpublic String getSQLData(String sqlText, String columnName)
sqlText - the SQL statementcolumnName - the column name of the desired column valuepublic String getSingleParamSQLData(String firstParam, String sqlText, String columnName)
firstParam - the first parameter valuesqlText - the SQL statementcolumnName - the column name of the desired column valuepublic int getCount(ResultSet rs)
public ResultSet getSingleParamSQL(String paramValue, String sqlText)
firstParam - the first parameter valuesqlText - the SQL statementpublic ResultSet getDoubleParamSQL(String firstParam, String secondParam, String sqlText)
firstParam - the first parameter valuesecondParam - the second parameter valuesqlText - the SQL statementpublic ResultSet getDoubleParamSQL(int firstParam, String secondParam, String sqlText)
firstParam - the first parameter valuesecondParam - the second parameter valuesqlText - the SQL statementpublic ResultSet getDoubleParamSQL(int firstParam, int secondParam, String sqlText)
firstParam - the first parameter valuesecondParam - the second parameter valuesqlText - the SQL statementpublic int getSequentialID(String tableName, String idColName)
tableName - required table namepublic int getSequentialID(String tableName, String idColName, String whereColumnName, String whereColumnValue)
tableName - required table namepublic int getSequenceValue(String seqName)
public boolean isExist(ResultSet rsRecords)
rsRecords - The result set to be checkedpublic boolean isSingleExist(String firstParam, String sqlText)
firstParam - The first parameter valuesqlText - The SQL textpublic boolean isExist(String sqlText)
firstParam - The first parameter valuesqlText - The SQL textpublic boolean isDoubleExist(String firstParam, String secondParam, String sqlText)
firstParam - The first parameter valuesecondParam - The second parameter valuesqlText - The SQL textpublic boolean isTrippleExist(String firstParam, String secondParam, String thirdParam, String sqlText)
firstParam - The first parameter valuesecondParam - The second parameter valuethirdParam - The third parameter valuesqlText - The SQL textpublic ResultSet fetchTableData(String tableName)
tableName - commentspublic HashMap<String,Field> FetchTableFields(String TableName, String FieldName, String FieldValue)
TableName - the target table of dataFieldName - the target table column representing the field NameFieldValue - the target table column representing the field Valuepublic void FillColumnNames(ResultSetMetaData rsMetaData, HashMap<String,Integer> results)
public static String getStringIndex(int digitWidth, int index)
digitWidth - the width of the required digitspublic void handleDBError(Exception ex)
public static String constructSingleParamProcedureCall(String ProcedureName)
public static String constructDoubleParamProcedureCall(String ProcedureName)
public static String constructTrippleParamProcedureCall(String ProcedureName)
public static String constructSingleParamFunctionCall(String functionName)
public static String constructDoubleParamFunctionCall(String functionName)
public static String constructTrippleParamFunctionCall(String functionName)
public static String constructMultiParamFunctionCall(String functionName, int paramsNo)
public static String constructMultiParamProcedureCall(String ProcedureName, int paramsNo)
protected static String getParamsText(int paramsNo)
public void executeDoubleParamFunction(String function, String param1, String param2)
public void executeTrippleParamFunction(String function, String param1, String param2, String param3)
public void executeDoubleParamFunction(String function, int param1, int param2)
public void executeMultiParamProcedure(String procedure, String[] params)
public void executeDoubleParamProcedure(String procedure, int param1, int param2)
public void executeDoubleParamProcedure(String procedure, String param1, String param2)
public void executeTrippleParamProcedure(String procedure, String param1, int param2, int param3)
public Connection getConnection()
public void importFile(String targetTable, String fileName) throws Exception
Exceptionpublic static int getErrorCategory(Exception ex)
public String createInsertSQL(String tableName) throws SQLException
SQLExceptionpublic Vector<TableColumn> getTableCols(String tableName) throws SQLException
SQLExceptionCopyright © 2019 SMYLD. All rights reserved.