public class JDBCQueryService
extends java.lang.Object
PhysicalDataContainer
for CRUD operations on the physical entities.
Use the mediation classes that implement the BusinessObjectManager
for CRUD
operations on the nouns and noun parts.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
Constructor and Description |
---|
JDBCQueryService(java.lang.String astrComponentId)
Constructor for the JDBCQueryService.
|
Modifier and Type | Method and Description |
---|---|
int[] |
executeBatchUpdate(java.lang.String astrQueryName,
java.util.List alParametersForBatchedQueries)
This method submits a batch of commands to the database.
|
int[] |
executeBatchUpdate(java.lang.String astrQueryName,
java.util.List alParametersForBatchedQueries,
boolean updateInWorkspace)
This method submits a batch of commands to the database.
|
int[] |
executeBatchUpdateWithStatement(java.lang.String astrStatement,
java.lang.String tableName,
java.util.List alParametersForBatchedQueries,
boolean updateInWorkspace)
This method submits a batch of commands to the database.
|
java.util.List |
executeDirectSQLQuery(java.lang.String sqlQuery,
java.util.Map aQueryParameters)
Executes the specified SQL statement defined in the query template and
returns the result.
|
java.util.List |
executeQuery(java.lang.String astrQueryName,
java.util.Map aQueryParameters)
Executes the specified SQL statement defined in the query template and
returns the result.
|
java.util.List |
executeQuery(java.lang.String astrQueryName,
java.util.Map aQueryParameters,
int startPageNumber,
int numberOfPage)
Executes the specified SQL statement defined in the query template and
returns the result.
|
java.util.List |
executeQuery(java.lang.String astrQueryName,
java.util.Map aQueryParameters,
int startPageNumber,
int numberOfPage,
int maxRows)
Executes the specified SQL statement defined in the query template and
returns the result.
|
int |
executeSQLUpdate(java.lang.String aSQLQuery,
java.util.Map aQueryParameters,
java.lang.Long anOptCounter,
java.lang.String[] arrTableNames)
This method executes the insert, update or delete SQL statement defined
in the SQL input parameter.
|
int |
executeUpdate(java.lang.String astrQueryName,
java.util.Map aQueryParameters)
This method executes the insert, update or delete SQL statement defined
in a query template file.
|
int |
executeUpdate(java.lang.String astrQueryName,
java.util.Map aQueryParameters,
java.lang.Long anOptCounter)
This method executes the insert, update or delete SQL statement defined
in a query template file.
|
java.sql.Timestamp |
getCurrentTimestamp()
Gets the current timestamp according to the Commerce Server database.
|
java.util.List |
myExecuteQuery()
This method is intended to be used internally by this class.
|
void |
setConnection(java.sql.Connection aConnection)
Passes a database connection to be used by this class.
|
public static final java.lang.String COPYRIGHT
public JDBCQueryService(java.lang.String astrComponentId)
astrComponentId
- -
component identifier.public int executeUpdate(java.lang.String astrQueryName, java.util.Map aQueryParameters) throws java.sql.SQLException, QueryServiceApplicationException
astrQueryName
- the name of the query in the query template fileaQueryParameters
- a map that contains the parameter name as a map key and a list
of values. Multiple values are specified for queries that use
the SQL 'IN' operator.java.sql.SQLException
- if a database access error occursQueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public int executeUpdate(java.lang.String astrQueryName, java.util.Map aQueryParameters, java.lang.Long anOptCounter) throws java.sql.SQLException, QueryServiceApplicationException
astrQueryName
- the name of the query in the query template fileaQueryParameters
- a map that contains the parameter name as a map key and a list
of values. Multiple values are specified for queries that use
the SQL 'IN' operator.anOptCounter
- the value of the optimistic collision columnjava.sql.SQLException
- if a database access error occursQueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public int executeSQLUpdate(java.lang.String aSQLQuery, java.util.Map aQueryParameters, java.lang.Long anOptCounter, java.lang.String[] arrTableNames) throws java.sql.SQLException, QueryServiceApplicationException
aSQLQuery
- the SQL statement with parameter markers to execute in this method.aQueryParameters
- a map that contains the parameter name as a map key and a list
of values. Multiple values are specified for queries that use
the SQL 'IN' operator.anOptCounter
- the value of the optimistic collision columnarrTableNames
- the string array of table name(s) associated to this SQL update for cache invalidation
purposesjava.sql.SQLException
- if a database access error occursQueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public int[] executeBatchUpdate(java.lang.String astrQueryName, java.util.List alParametersForBatchedQueries) throws java.sql.SQLException, java.sql.BatchUpdateException, QueryServiceApplicationException
Statement
interface.astrQueryName
- the name of the query in the query template filealParametersForBatchedQueries
- List of NamedQueryParameters
objects. The set of
parameters in each object should be valid for a given query.
Each object should have exactly the same set of parameter names.java.sql.SQLException
- if a database access error occurs or the driver does not
support batch statements.java.sql.BatchUpdateException
- (a subclass of SQLException)
if one of the commands sent to the database fails to execute
properly or attempts to return a result set.QueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public int[] executeBatchUpdate(java.lang.String astrQueryName, java.util.List alParametersForBatchedQueries, boolean updateInWorkspace) throws java.sql.SQLException, java.sql.BatchUpdateException, QueryServiceApplicationException
Statement
interface.astrQueryName
- the name of the query in the query template filealParametersForBatchedQueries
- List of NamedQueryParameters
objects. The set of
parameters in each object should be valid for a given query.
Each object should have exactly the same set of parameter names.updateInWorkspace
- if set to true, then a check is performed to determine if the method is called in the context of workspace. If yes, then
updates are performed one by one for each named query parameter. If the method is called in base, then a batch update is performed.java.sql.SQLException
- if a database access error occurs or the driver does not
support batch statements.java.sql.BatchUpdateException
- (a subclass of SQLException)
if one of the commands sent to the database fails to execute
properly or attempts to return a result set.QueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public int[] executeBatchUpdateWithStatement(java.lang.String astrStatement, java.lang.String tableName, java.util.List alParametersForBatchedQueries, boolean updateInWorkspace) throws java.sql.SQLException, java.sql.BatchUpdateException, QueryServiceApplicationException
Statement
interface.astrStatement
- the statement to be executedtableName
- the tablename to be executed onalParametersForBatchedQueries
- List of NamedQueryParameters
objects. The set of
parameters in each object should be valid for a given query.
Each object should have exactly the same set of parameter names.updateInWorkspace
- if set to true, then a check is performed to determine if the method is called in the context of workspace. If yes, then
updates are performed one by one for each named query parameter. If the method is called in base, then a batch update is performed.java.sql.SQLException
- if a database access error occurs or the driver does not
support batch statements.java.sql.BatchUpdateException
- (a subclass of SQLException)
if one of the commands sent to the database fails to execute
properly or attempts to return a result set.QueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public java.util.List executeQuery(java.lang.String astrQueryName, java.util.Map aQueryParameters) throws java.sql.SQLException, QueryServiceApplicationException
SELECT
statement.astrQueryName
- the name of the query in the query template fileaQueryParameters
- a map that contains the parameter name as a map key and a list
of values. Multiple values are specified for queries that use
the SQL 'IN' operator.java.sql.SQLException
- if there is a problem with the connection from the
datasource or executing the SQL statement.QueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public java.util.List executeDirectSQLQuery(java.lang.String sqlQuery, java.util.Map aQueryParameters) throws java.sql.SQLException, QueryServiceApplicationException
SELECT
statement.sqlQuery
- the direct query stringaQueryParameters
- a map that contains the parameter name as a map key and a list
of values. Multiple values are specified for queries that use
the SQL 'IN' operator.java.sql.SQLException
- if there is a problem with the connection from the
datasource or executing the SQL statement.QueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public java.util.List executeQuery(java.lang.String astrQueryName, java.util.Map aQueryParameters, int startPageNumber, int numberOfPage) throws java.sql.SQLException, QueryServiceApplicationException
SELECT
statement.astrQueryName
- the name of the query in the query template fileaQueryParameters
- a map that contains the parameter name as a map key and a list
of values. Multiple values are specified for queries that use
the SQL 'IN' operator.startPageNumber
- the start page number for pagination.numberOfPage
- the number of rows in a page pagination.
The totalNumber is a
The records list is a Integer
value that should be got by list.get(0)
List
object that should be got by list.get(1),
each element in the records list is a record of the result set. Each record is
a HashMap where the key is the column name and the value is the
column value. An empty list is returned if no records are
returned from the query.
java.sql.SQLException
- if there is a problem with the connection from the
datasource or executing the SQL statement.QueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public java.util.List executeQuery(java.lang.String astrQueryName, java.util.Map aQueryParameters, int startPageNumber, int numberOfPage, int maxRows) throws java.sql.SQLException, QueryServiceApplicationException
SELECT
statement.astrQueryName
- the name of the query in the query template fileaQueryParameters
- a map that contains the parameter name as a map key and a list
of values. Multiple values are specified for queries that use
the SQL 'IN' operator.startPageNumber
- the start page number for pagination.numberOfPage
- the number of rows in a page pagination.maxRows
- the max rows that should be returned.
The totalNumber is a
The records list is a Integer
value that should be got by list.get(0)
List
object that should be got by list.get(1),
each element in the records list is a record of the result set. Each record is
a HashMap where the key is the column name and the value is the
column value. An empty list is returned if no records are
returned from the query.
java.sql.SQLException
- if there is a problem with the connection from the
datasource or executing the SQL statement.QueryServiceApplicationException
- if an error occurred during getting query template
information based on the specified query name.public final java.util.List myExecuteQuery() throws java.sql.SQLException
java.sql.SQLException
public java.sql.Timestamp getCurrentTimestamp() throws java.sql.SQLException
java.sql.SQLException
- if there is a problem with the connection from the datasource or
executing the SQL statement.public void setConnection(java.sql.Connection aConnection)
aConnection
- - database connection