public class DatabaseQuery extends Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DatabasePerf |
static boolean |
DatabaseQueryDataPerf |
static boolean |
DatabaseQueryPerf |
protected Timer |
timerDB |
protected Timer |
timerDBData |
protected Timer |
timerDBQuery |
| Constructor and Description |
|---|
DatabaseQuery()
Creates a new
BaseInputAdapter instance. |
DatabaseQuery(String aPoolName)
Creates a new
BaseInputAdapter instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
addBatch(String aSqlStr) |
static String |
buildInsertSqlString(String aTableName,
List<DataStoreParamIntf> aList) |
static String |
buildUpdateSqlString(String aTableName,
List<DataStoreParamIntf> aList) |
void |
cleanUp() |
void |
clearBatch() |
void |
createMetadata(String aRefName,
String aSql) |
int[] |
doBatch() |
int[] |
doBatch(String aSqlStr,
int aNumberRows,
List<DataStoreParamIntf> aParams) |
int[] |
doBatchSQL(String aSqlStr,
List<DataStoreParamIntf> aFields,
List<Map<String,Object>> aParams)
This method
doBatch executes all SQL statements from addBatch
and the number of rows affected are returned. |
void |
doCommit(boolean aCommit) |
void |
doCountQuery(String aSql,
List<DataStoreParamIntf> aParams) |
void |
doCountQuery(String aSql,
List<Object> aParams,
boolean aFlag) |
int[] |
doFakeBatch(String aSqlStr,
int aNumberRows,
List<DataStoreParamIntf> aParams)
This method
doBatch executes all SQL statements from addBatch
and the number of rows affected are returned. |
void |
doQuery(String aRefName,
String aSqlStr)
This method
doQuery executes the specified SQL |
void |
doQuery(String aRefName,
String aSqlStr,
List<DataStoreParamIntf> aParams)
This method
doQuery executes the specified SQL |
void |
doQuery(String aRefName,
String aSqlStr,
List<Object> aParams,
boolean aListIsParams)
This method
doQuery executes the specified SQL |
int |
doSQL(String aSqlStr)
This method
doSql executes the specified SQL and returns
a row count for the number of rows affected. |
int |
doSQL(String aSqlStr,
List<DataStoreParamIntf> aParams)
This method
doSql executes the specified SQL and returns
a row count for the number of rows affected. |
int |
doSQL(String aSqlStr,
List<Object> aParams,
boolean aListIsParams)
This method
doSql executes the specified SQL and returns
a row count for the number of rows affected. |
int |
doSQLFromFile(File f) |
int |
doSQLStatement(String aSqlStr)
This method
doSql executes the specified SQL
and assumes that there are no input parameters to this query. |
void |
doStoredProcedure(String aStoredProcedureName,
String[] aParams)
This method
doStoredProcedure executes the
specified Stored Procedure |
int |
doStoredProcedure(String aStoredProcedureName,
String[] aParams,
boolean isFunction) |
int |
doStoredProcedureOracle(String aStoredProcedureName,
String[] aParams) |
StringBuffer |
doStoredProcedureOracleString(String aStoredProcedureName,
String[] aParams,
DataView os2) |
StringBuffer |
doStoredProcedureString(String aStoredProcedureName,
String[] aParams) |
void |
doTransaction() |
static String |
generateInSqlTemplate(String sql,
int parameterCount)
Given a a SQL statement containing the IN predicate and the count of
values to be applied to the IN predicate, massages the statement to return
one that is valid JDBC PreparedStatement syntax.
|
String |
getCountSql(String aSql) |
Integer |
getCursorType() |
String |
getDatabasePoolName() |
DataSourceIntf |
getDataSource() |
DataView |
getDataView(String aRefName) |
DBAccessIntf |
getDBAccess() |
List<DataStoreParamIntf> |
getDBParams(String aRefName) |
int |
getDefError() |
MetadataIntf |
getMetadata(String aRefName) |
long |
getQueryRecordCount() |
int |
getStartRange() |
String |
getXmlData(String aRefName) |
String |
getXmlData(String aRefName,
String aRowTag) |
String |
getXmlData(String aRefName,
String aRootTag,
String aRowTag) |
boolean |
isNoCursorFlag() |
boolean |
isOracle() |
boolean |
isQueryRecordCount() |
boolean |
isSQLServer() |
protected String |
loadFileToString(File aFile) |
String |
logDbParams(String aSqlStr,
List<DataStoreParamIntf> aParams) |
String |
logParams(String aSqlStr,
List<Object> aParams) |
void |
removeMetadata(String aRefName) |
void |
resetQueryRange() |
void |
setClearData(boolean aFlag) |
void |
setCursorType(Integer aCursorType) |
int |
setData(String aRefName,
ResultSet rs)
Will load all the data from the result query to Storage Object
|
void |
setDatabasePool(String aPoolName) |
void |
setDataMapFlag(boolean aFlag) |
void |
setDataMapType(boolean aFlag,
String aDateFormat) |
void |
setMetadata(String aRefName,
MetadataIntf aMetadata) |
void |
setNoCursorFlag(boolean aFlag) |
void |
setParam2(PreparedStatement aStatement,
int aType,
Object aValue,
int aPosition) |
void |
setQueryRange(int aStartRow,
int aMaxRows) |
void |
setQueryRecordCount(boolean aFlag) |
void |
setQueueSQLWriter(QueueWriter aWriter) |
void |
setTrimFlag(boolean aTrimFlag) |
void |
turnOfflogging(boolean aFlag) |
public static boolean DatabaseQueryPerf
public static boolean DatabaseQueryDataPerf
public static boolean DatabasePerf
protected Timer timerDB
protected Timer timerDBQuery
protected Timer timerDBData
public DatabaseQuery()
BaseInputAdapter instance.
This class is abstractpublic void turnOfflogging(boolean aFlag)
public boolean isSQLServer()
public boolean isOracle()
public boolean isNoCursorFlag()
public void setNoCursorFlag(boolean aFlag)
public Integer getCursorType()
public void setCursorType(Integer aCursorType)
public void setTrimFlag(boolean aTrimFlag)
public void setDataMapFlag(boolean aFlag)
public void setDataMapType(boolean aFlag,
String aDateFormat)
public String getDatabasePoolName()
public DataSourceIntf getDataSource()
public DBAccessIntf getDBAccess()
public void setClearData(boolean aFlag)
public void doQuery(String aRefName, String aSqlStr, List<DataStoreParamIntf> aParams) throws Exception
doQuery executes the specified SQL
aRefName - String Buffer Storage/Metadata NameaSqlStr - String ANSII Sql StringaParams - List A Set of DB Params for SQL StatementException - expublic void doQuery(String aRefName, String aSqlStr, List<Object> aParams, boolean aListIsParams) throws Exception
doQuery executes the specified SQL
aRefName - String Buffer Storage/Metadata NameaSqlStr - String ANSII Sql StringaParams - List A Set of DB Params for SQL StatementaListIsParams - listException - expublic void doQuery(String aRefName, String aSqlStr) throws Exception
doQuery executes the specified SQL
aRefName - String Buffer Storage/Metadata NameaSqlStr - String ANSII Sql StringException - expublic void doCountQuery(String aSql, List<DataStoreParamIntf> aParams) throws Exception
Exceptionpublic void doCountQuery(String aSql, List<Object> aParams, boolean aFlag) throws Exception
Exceptionpublic boolean isQueryRecordCount()
public void setQueryRecordCount(boolean aFlag)
public long getQueryRecordCount()
public void doStoredProcedure(String aStoredProcedureName, String[] aParams) throws Exception
doStoredProcedure executes the
specified Stored ProcedureaStoredProcedureName - String Name of the Stroed ProcedureaParams - String Array of parametersException - expublic int doStoredProcedure(String aStoredProcedureName, String[] aParams, boolean isFunction) throws Exception
Exceptionpublic StringBuffer doStoredProcedureString(String aStoredProcedureName, String[] aParams) throws Exception
Exceptionpublic StringBuffer doStoredProcedureOracleString(String aStoredProcedureName, String[] aParams, DataView os2) throws Exception
Exceptionpublic void doTransaction()
throws SQLException
SQLExceptionpublic void doCommit(boolean aCommit)
throws SQLException
SQLExceptionprotected String loadFileToString(File aFile) throws IOException
IOExceptionpublic int doSQL(String aSqlStr) throws Exception
doSql executes the specified SQL and returns
a row count for the number of rows affected.aSqlStr - String ANSII Sql StringException - expublic int doSQLStatement(String aSqlStr) throws Exception
doSql executes the specified SQL
and assumes that there are no input parameters to this query. (it is a Statement, not a PreparedStatement)
returns 1 if the next result is a ResultSet object;
0 if it is an update count or there are no more resultsaSqlStr - String ANSII Sql StringException - expublic int doSQL(String aSqlStr, List<DataStoreParamIntf> aParams) throws Exception
doSql executes the specified SQL and returns
a row count for the number of rows affected.
aSqlStr - String ANSII Sql StringaParams - List A Set of DB Params for SQL StatementException - expublic int doSQL(String aSqlStr, List<Object> aParams, boolean aListIsParams) throws Exception
doSql executes the specified SQL and returns
a row count for the number of rows affected.
aSqlStr - String ANSII Sql StringaParams - List A Set of DB Params for SQL StatementaListIsParams - listException - exceptionpublic void addBatch(String aSqlStr)
aSqlStr - String ANSII Sql Stringpublic void clearBatch()
public int[] doBatchSQL(String aSqlStr, List<DataStoreParamIntf> aFields, List<Map<String,Object>> aParams) throws Exception
doBatch executes all SQL statements from addBatch
and the number of rows affected are returned.
aSqlStr - String ANSII Sql StringaFields - fieldsaParams - List A Set of DB Params for SQL StatementException - expublic int[] doBatch(String aSqlStr, int aNumberRows, List<DataStoreParamIntf> aParams) throws Exception
Exceptionpublic int[] doFakeBatch(String aSqlStr, int aNumberRows, List<DataStoreParamIntf> aParams) throws Exception
doBatch executes all SQL statements from addBatch
and the number of rows affected are returned.
aSqlStr - String ANSII Sql StringaNumberRows - rowsaParams - List A Set of DB Params for SQL StatementException - expublic void setParam2(PreparedStatement aStatement, int aType, Object aValue, int aPosition) throws SQLException
SQLExceptionpublic void setMetadata(String aRefName, MetadataIntf aMetadata)
public void removeMetadata(String aRefName)
public void cleanUp()
public MetadataIntf getMetadata(String aRefName)
public int setData(String aRefName, ResultSet rs)
aRefName - String Metadata Reference Namers - ResultSet Query Resultpublic void setQueryRange(int aStartRow,
int aMaxRows)
public int getStartRange()
public void resetQueryRange()
public int getDefError()
public void createMetadata(String aRefName, String aSql) throws Exception
Exceptionpublic List<DataStoreParamIntf> getDBParams(String aRefName)
public static String buildInsertSqlString(String aTableName, List<DataStoreParamIntf> aList)
public static String buildUpdateSqlString(String aTableName, List<DataStoreParamIntf> aList)
public static String generateInSqlTemplate(String sql, int parameterCount) throws Exception
sql - Original SQL with $ for IN clause paramters.parameterCount - Number of IN parameters.Exception - if an invalid condition is encountered.public String logParams(String aSqlStr, List<Object> aParams) throws Exception
Exceptionpublic String logDbParams(String aSqlStr, List<DataStoreParamIntf> aParams) throws Exception
Exceptionpublic void setQueueSQLWriter(QueueWriter aWriter)
Copyright © 2020. All rights reserved.