org.midao.jdbc.core.service
Interface QueryRunnerService

All Known Implementing Classes:
AbstractQueryRunner, QueryRunner

public interface QueryRunnerService

Core Service of Midao. Executes all type of Queries.


Method Summary
 int[] batch(InputHandler[] inputHandlers)
          Execute a batch of SQL INSERT, UPDATE, or DELETE queries.
 int[] batch(java.lang.String sql, java.lang.Object[][] params)
          Execute a batch of SQL INSERT, UPDATE, or DELETE queries.
<T> T
call(AbstractNamedInputHandler<T> inputHandler)
          Executes the given CALL SQL statement.
<T> T
call(AbstractNamedInputHandler<T> inputHandler, java.lang.String catalog, java.lang.String schema, boolean useCache)
          Executes the given CALL SQL statement.
 QueryParameters call(AbstractQueryInputHandler inputHandler)
          Executes the given CALL SQL statement.
<T,S> CallResults<T,S>
call(InputHandler<T> inputHandler, OutputHandler<S> outputHandler)
          Executes the given CALL SQL statement.
<T,S> CallResults<T,S>
call(InputHandler<T> inputHandler, OutputHandler<S> outputHandler, java.lang.String catalog, java.lang.String schema, boolean useCache)
          Executes the given CALL SQL statement.
 void commit()
          Commits current Transaction Usable only when setTransactionManualMode(boolean) set as true
 java.lang.Integer getTransactionIsolationLevel()
          Returns current Transaction Isolation level
 boolean isTransactionManualMode()
          Returns current Transaction mode
 QueryRunnerService override(java.lang.String operation, java.lang.Object value)
          Adds override which would be used until removed.
 QueryRunnerService overrideOnce(java.lang.String operation, java.lang.Object value)
          Adds override which would be used only once.
<T> T
query(InputHandler inputHandler, OutputHandler<T> outputHandler)
          Executes the given SELECT SQL query and returns a result object.
<T> T
query(java.lang.String sql, OutputHandler<T> outputHandler)
          Executes the given SELECT SQL without any replacement parameters.
<T> T
query(java.lang.String sql, OutputHandler<T> outputHandler, java.lang.Object... params)
          Executes the given SELECT SQL query and returns a result object.
 void releaseSavepoint(java.sql.Savepoint savepoint)
          Removes the specified Savepoint and subsequent Savepoint objects from the current transaction.
 QueryRunnerService removeOverride(java.lang.String operation)
          Removes override.
 void rollback()
          Rollbacks current Transaction Usable only when setTransactionManualMode(boolean) set as true
 void rollback(java.sql.Savepoint savepoint)
          Undoes all changes made after the given Savepoint object was set.
 java.sql.Savepoint setSavepoint()
          Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.
 java.sql.Savepoint setSavepoint(java.lang.String name)
          Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.
 void setTransactionIsolationLevel(java.lang.Integer level)
          Transaction Isolation level.
 void setTransactionManualMode(boolean manualMode)
          Sets Transaction mode.
 int update(InputHandler inputHandler)
          Executes the given INSERT, UPDATE, or DELETE SQL statement.
<T> T
update(InputHandler inputHandler, OutputHandler<T> outputHandler)
          Executes the given INSERT, UPDATE, or DELETE SQL statement.
 int update(java.lang.String sql)
          Executes the given INSERT, UPDATE, or DELETE SQL statement without any replacement parameters.
 int update(java.lang.String sql, java.lang.Object... params)
          Executes the given INSERT, UPDATE, or DELETE SQL statement.
 int update(java.lang.String sql, java.lang.Object param)
          Executes the given INSERT, UPDATE, or DELETE SQL statement with a single replacement parameter.
<T> T
update(java.lang.String sql, OutputHandler<T> outputHandler, java.lang.Object... params)
          Executes the given INSERT, UPDATE, or DELETE SQL statement.
 

Method Detail

batch

int[] batch(java.lang.String sql,
            java.lang.Object[][] params)
            throws java.sql.SQLException
Execute a batch of SQL INSERT, UPDATE, or DELETE queries.

Parameters:
sql - The SQL to execute.
params - An array of query replacement parameters. Each row in this array is one set of batch replacement values.
Returns:
Array with number of rows updated per statement.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

batch

int[] batch(InputHandler[] inputHandlers)
            throws java.sql.SQLException
Execute a batch of SQL INSERT, UPDATE, or DELETE queries.

Parameters:
inputHandlers - Input Handler which would be executed
Returns:
Array with number of rows updated per statement.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

query

<T> T query(java.lang.String sql,
            OutputHandler<T> outputHandler,
            java.lang.Object... params)
        throws java.sql.SQLException
Executes the given SELECT SQL query and returns a result object.

Type Parameters:
T - The type of object that the handler returns
Parameters:
sql - The SQL statement to execute.
outputHandler - The handler used to create the result object from Query output
params - Initialize the PreparedStatement's IN parameters with this array.
Returns:
An object generated by the handler.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

query

<T> T query(InputHandler inputHandler,
            OutputHandler<T> outputHandler)
        throws java.sql.SQLException
Executes the given SELECT SQL query and returns a result object.

Type Parameters:
T - The type of object that the handler returns
Parameters:
inputHandler - Input Handler which would be executed
outputHandler - The handler used to create the result object from Query output
Returns:
An object generated by the handler.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

query

<T> T query(java.lang.String sql,
            OutputHandler<T> outputHandler)
        throws java.sql.SQLException
Executes the given SELECT SQL without any replacement parameters.

Type Parameters:
T - The type of object that the handler returns
Parameters:
sql - The SQL statement to execute.
outputHandler - The handler used to create the result object from Query output
Returns:
An object generated by the handler.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

update

int update(java.lang.String sql)
           throws java.sql.SQLException
Executes the given INSERT, UPDATE, or DELETE SQL statement without any replacement parameters.

Parameters:
sql - The SQL statement to execute.
Returns:
The number of rows updated.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

update

int update(java.lang.String sql,
           java.lang.Object param)
           throws java.sql.SQLException
Executes the given INSERT, UPDATE, or DELETE SQL statement with a single replacement parameter.

Parameters:
sql - The SQL statement to execute.
param - The replacement parameter.
Returns:
The number of rows updated.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

update

int update(java.lang.String sql,
           java.lang.Object... params)
           throws java.sql.SQLException
Executes the given INSERT, UPDATE, or DELETE SQL statement.

Parameters:
sql - The SQL statement to execute.
params - Initializes the PreparedStatement's IN (i.e. '?') parameters.
Returns:
The number of rows updated.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

update

int update(InputHandler inputHandler)
           throws java.sql.SQLException
Executes the given INSERT, UPDATE, or DELETE SQL statement.

Parameters:
inputHandler - Input Handler which would be executed
Returns:
The number of rows updated.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

update

<T> T update(InputHandler inputHandler,
             OutputHandler<T> outputHandler)
         throws java.sql.SQLException
Executes the given INSERT, UPDATE, or DELETE SQL statement.

Type Parameters:
T - The type of object that the handler returns
Parameters:
inputHandler - Input Handler which would be executed
outputHandler - The handler used to create the result object from Query output
Returns:
An object generated by the handler.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

update

<T> T update(java.lang.String sql,
             OutputHandler<T> outputHandler,
             java.lang.Object... params)
         throws java.sql.SQLException
Executes the given INSERT, UPDATE, or DELETE SQL statement.

Type Parameters:
T - The type of object that the handler returns
Parameters:
sql - The SQL statement to execute.
outputHandler - The handler used to create the result object from Query output
params - Initializes the PreparedStatement's IN (i.e. '?') parameters.
Returns:
An object generated by the handler.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

call

QueryParameters call(AbstractQueryInputHandler inputHandler)
                     throws java.sql.SQLException
Executes the given CALL SQL statement. Allows execution of Stored Procedures/Functions

Parameters:
inputHandler - Input Handler which would be executed
Returns:
Query Output. All input parameters are updated from OUT parameters. Stored Function return is stored there as well. Can be received by invoking QueryParameters.getReturn()
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

call

<T> T call(AbstractNamedInputHandler<T> inputHandler)
       throws java.sql.SQLException
Executes the given CALL SQL statement. Allows execution of Stored Procedures/Functions This function reads database metadata and identifies OUT fields. Output from OUT fields is merged with input and returned as function return. If function fails during reading database metadata please use call(org.midao.jdbc.core.handlers.input.query.AbstractQueryInputHandler) as it is possible to specify Direction in QueryParameters class

Type Parameters:
T - The type of object that the handler returns
Parameters:
inputHandler - Input Handler which would be executed
Returns:
An object generated by the handler.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

call

<T> T call(AbstractNamedInputHandler<T> inputHandler,
           java.lang.String catalog,
           java.lang.String schema,
           boolean useCache)
       throws java.sql.SQLException
Executes the given CALL SQL statement. Allows execution of Stored Procedures/Functions This function reads database metadata and identifies OUT fields. Output from OUT fields is merged with input and returned as function return. If function fails during reading database metadata please use call(org.midao.jdbc.core.handlers.input.query.AbstractQueryInputHandler) as it is possible to specify Direction in QueryParameters class

Type Parameters:
T - The type of object that the handler returns
Parameters:
inputHandler - Input Handler which would be executed
catalog - Database Catalog. If null would be specified - this value won't be used in search
schema - Database Schema. If null would be specified - this value won't be used in search
useCache - specifies if it should use cache for reading Stored Procedure/Function parameters
Returns:
An object generated by the handler.
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

call

<T,S> CallResults<T,S> call(InputHandler<T> inputHandler,
                            OutputHandler<S> outputHandler)
                      throws java.sql.SQLException
Executes the given CALL SQL statement. Allows execution of Stored Procedures/Functions This function reads database metadata and identifies OUT fields. Output from OUT fields is merged with input and returned as function return. If function fails during reading database metadata please use call(org.midao.jdbc.core.handlers.input.query.AbstractQueryInputHandler) as it is possible to specify Direction in QueryParameters class

Type Parameters:
T - The type of object that the input handler clones, updates and returns
S - The type of object that the output handler returns
Parameters:
inputHandler - Input Handler which would be executed
outputHandler - The handler used to create the result object from Query output
Returns:
CallResult which holds updated input and processed Query output (by OutputHandler)
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

call

<T,S> CallResults<T,S> call(InputHandler<T> inputHandler,
                            OutputHandler<S> outputHandler,
                            java.lang.String catalog,
                            java.lang.String schema,
                            boolean useCache)
                      throws java.sql.SQLException
Executes the given CALL SQL statement. Allows execution of Stored Procedures/Functions This function reads database metadata and identifies OUT fields. Output from OUT fields is merged with input and returned as function return. If function fails during reading database metadata please use call(org.midao.jdbc.core.handlers.input.query.AbstractQueryInputHandler) as it is possible to specify Direction in QueryParameters class

Type Parameters:
T - The type of object that the input handler clones, updates and returns
S - The type of object that the output handler returns
Parameters:
inputHandler - Input Handler which would be executed
outputHandler - The handler used to create the result object from Query output
catalog - Database Catalog. If null would be specified - this value won't be used in search
schema - Database Schema. If null would be specified - this value won't be used in search
useCache - specifies if it should use cache for reading Stored Procedure/Function parameters
Returns:
CallResult which holds updated input and processed Query output (by OutputHandler)
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

overrideOnce

QueryRunnerService overrideOnce(java.lang.String operation,
                                java.lang.Object value)
Adds override which would be used only once. Overriders provide wide variety of functionality. For whole list please look at MidaoConstants OVERRIDE_* Constants

Parameters:
operation - name of the operation
value - override value
Returns:
this instance of QueryRunner

override

QueryRunnerService override(java.lang.String operation,
                            java.lang.Object value)
Adds override which would be used until removed. Overriders provide wide variety of functionality. For whole list please look at MidaoConstants OVERRIDE_* Constants

Parameters:
operation - name of the operation
value - override value
Returns:
this instance of QueryRunner

removeOverride

QueryRunnerService removeOverride(java.lang.String operation)
Removes override. Overriders provide wide variety of functionality. For whole list please look at MidaoConstants OVERRIDE_* Constants

Parameters:
operation - name of the operation
Returns:
this instance of QueryRunner

setTransactionManualMode

void setTransactionManualMode(boolean manualMode)
Sets Transaction mode. By default system works in automatic mode. No additional actions is not required as every query execution would be committed right away. In manual mode every query execution is performed in current transaction. In order to commit changes execution of commit() is required.

Parameters:
manualMode - manual mode

isTransactionManualMode

boolean isTransactionManualMode()
Returns current Transaction mode

Returns:
current Transaction mode

setTransactionIsolationLevel

void setTransactionIsolationLevel(java.lang.Integer level)
Transaction Isolation level. For general information please look at Java Tutorials (docs.oracle.com/javase/tutorial/index.html) JDBC basics / Using Transactions For detailed information please look at vendor JDBC driver description

Parameters:
level - Transaction Isolation level

getTransactionIsolationLevel

java.lang.Integer getTransactionIsolationLevel()
Returns current Transaction Isolation level

Returns:
current Transaction Isolation level

commit

void commit()
            throws java.sql.SQLException
Commits current Transaction Usable only when setTransactionManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

rollback

void rollback()
              throws java.sql.SQLException
Rollbacks current Transaction Usable only when setTransactionManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

setSavepoint

java.sql.Savepoint setSavepoint()
                                throws java.sql.SQLException
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it. Connection.setSavepoint() Usable only when setTransactionManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

setSavepoint

java.sql.Savepoint setSavepoint(java.lang.String name)
                                throws java.sql.SQLException
Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it. Connection.setSavepoint(String) Usable only when setTransactionManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

rollback

void rollback(java.sql.Savepoint savepoint)
              throws java.sql.SQLException
Undoes all changes made after the given Savepoint object was set. Connection.rollback(java.sql.Savepoint) Usable only when setTransactionManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

releaseSavepoint

void releaseSavepoint(java.sql.Savepoint savepoint)
                      throws java.sql.SQLException
Removes the specified Savepoint and subsequent Savepoint objects from the current transaction. Connection.releaseSavepoint(java.sql.Savepoint) Usable only when setTransactionManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database


Copyright © 2013. All Rights Reserved.