Interface QueryManagerService
-
public interface QueryManagerService
This interface represents query manager services. A query manager service implements generic query execution methods for ease of development only. Note: TheQueryResult
instances that some of this class's methods return load the complete query result in memory. These methods should thus not be used for queries that potentially return large result sets because that might cause anOutOfMemoryException
.- Author:
- ivol
-
-
Field Summary
Fields Modifier and Type Field Description static String
INTERNAL_DBID
static String
MEDIAREPOSITORY_DBID
Identifier to use for accessing the media repository databasestatic String
TIMESTAMP_DBID
Identifier to use for accessing the default databasestatic String
WEBADMIN_DBID
Identifier to use for accessing the webadmin database
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description QueryResult
callStoredProcedure(DataSource datasource, String procedure, Object[] args)
Performs a stored procedure and returns the result.QueryResult
executeSelect(DataSource datasource, String statement, Object[] args)
Performs a select query and returns the result.boolean
executeStoredProcedure(DataSource datasource, String procedure, Object[] args)
Execute any stored procedureint
executeUpdate(DataSource datasource, String statement, Object[] args)
Executes a SQL statement that must be either a INSERT, UPDATE or DELETE statementint
getAsInt(Object object)
Returns an object that was returned as result of a query as an Integer.DataSource
getDataSourceById(String dbId)
Returns the datasource by the given database id.DataSource
getDataSourceByName(String fullDataSourceName)
Returns the datasource by the given full datasource name.
-
-
-
Field Detail
-
MEDIAREPOSITORY_DBID
static final String MEDIAREPOSITORY_DBID
Identifier to use for accessing the media repository database- See Also:
- Constant Field Values
-
TIMESTAMP_DBID
static final String TIMESTAMP_DBID
Identifier to use for accessing the default database- See Also:
- Constant Field Values
-
WEBADMIN_DBID
static final String WEBADMIN_DBID
Identifier to use for accessing the webadmin database- See Also:
- Constant Field Values
-
INTERNAL_DBID
static final String INTERNAL_DBID
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDataSourceById
DataSource getDataSourceById(String dbId) throws SQLException
Returns the datasource by the given database id. It will retrieve the datasource name from the configuration management service and the database id provided should equal the name of the parameter under which the full datasource name is stored. It is recommended to use the predefined database ids in this interface. For example:getDataSourceById(QueryManagerService.WEBADMIN_DBID);
- Parameters:
dbId
- Database id of which the datasource should be retrieved- Returns:
- The datasource for the given database id
- Throws:
SQLException
- in case an error occurred while retrieving the datasource
-
getDataSourceByName
DataSource getDataSourceByName(String fullDataSourceName) throws SQLException
Returns the datasource by the given full datasource name.- Parameters:
fullDataSourceName
- Datasource name of the datasource to retrieve- Returns:
- Datasource for the given DataSource name
- Throws:
SQLException
- in case an error occurred while retrieving the datasource
-
executeSelect
QueryResult executeSelect(DataSource datasource, String statement, Object[] args) throws SQLException
Performs a select query and returns the result.- Parameters:
datasource
- Datasource to execute the query onstatement
- Statement to execute. Recommended is to use prepared statements.args
- Input arguments of the statement in case of prepared statements.- Returns:
- The results of the query QueryResult object.
- Throws:
SQLException
- If a SQL exception occurred
-
executeUpdate
int executeUpdate(DataSource datasource, String statement, Object[] args) throws SQLException
Executes a SQL statement that must be either a INSERT, UPDATE or DELETE statement- Parameters:
datasource
- Datasource to execute the stored procedure onprocedure
- Stored procedure to execute.args
- Input arguments of the stored procedure.- Returns:
- either (1) the row count for INSERT, UPDATE, or DELETE statements or (2) 0 for SQL statements that return nothing
- Throws:
SQLException
- If a SQL exception occurred
-
executeStoredProcedure
boolean executeStoredProcedure(DataSource datasource, String procedure, Object[] args) throws SQLException
Execute any stored procedure- Parameters:
datasource
- Datasource to execute the stored procedure onprocedure
- Stored procedure to execute.args
- Input arguments of the stored procedure.- Returns:
- The execute method returns a boolean to indicate the form of the first result.
- Throws:
SQLException
- If a SQL exception occurred
-
callStoredProcedure
QueryResult callStoredProcedure(DataSource datasource, String procedure, Object[] args) throws SQLException
Performs a stored procedure and returns the result.- Parameters:
datasource
- Datasource to execute the stored procedure onprocedure
- Stored procedure to execute.args
- Input arguments of the stored procedure.- Returns:
- The results of the query QueryResult object.
- Throws:
SQLException
- If a SQL exception occurred
-
getAsInt
int getAsInt(Object object)
Returns an object that was returned as result of a query as an Integer. This is necessary for the generic executeSelect since a getObject on a number result in oracle does not return an Integer but a BigDecimal- Parameters:
object
- Object of the result query to be converted to an Integer- Returns:
- Value of the object as Integer
- Throws:
IllegalArgumentException
- if the object is not an Integer, BigInteger or BigDecimal
-
-