Class SQLParameterizedQueryEvaluator
java.lang.Object
fr.inria.rules.integraal.storage.external.evaluator.SQLParameterizedQueryEvaluator
- All Implemented Interfaces:
NativeQueryEvaluator<SQLParameterizedQuery, List<Object[]>>
public class SQLParameterizedQueryEvaluator
extends Object
implements NativeQueryEvaluator<SQLParameterizedQuery, List<Object[]>>
Evaluates a SQL query using the associated driver.
This evaluator uses Apache's
This evaluator also provides additional methods for inserting data on the database.
QueryRunner to execute the query on the database
The result is a List<Object[]> which represents the list of all resulting tuples.
This evaluator also provides additional methods for inserting data on the database.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new evaluator over the database represented by the given driver -
Method Summary
Modifier and TypeMethodDescriptionbooleanCopies CSV data using the supplied SQL copy statement.booleancopyFromSTDIn(String sqlCopyQuery, String csvFileName) Copies CSV data from standard input using the supplied SQL copy statement.evaluate(SQLParameterizedQuery query) Evaluate the given query and returns the result This should not do anymore workbooleanExecutes the SQL statements stored in the supplied file.booleaninsert(SQLParameterizedQuery query) Execute the given insert querybooleaninsertBatch(String query, List<Object[]> parameters) Insert the given values, using a batch insert and parameters for the query This is more efficient than looping over the parameters and executing each query at a time
-
Constructor Details
-
SQLParameterizedQueryEvaluator
Construct a new evaluator over the database represented by the given driver- Parameters:
driver- representing the database to connect to- Throws:
SQLException- if the initial connection to the database cannot be performed
-
-
Method Details
-
evaluate
Description copied from interface:NativeQueryEvaluatorEvaluate the given query and returns the result This should not do anymore work- Specified by:
evaluatein interfaceNativeQueryEvaluator<SQLParameterizedQuery, List<Object[]>>- Parameters:
query- to evaluate- Returns:
- an optional which contains the results of the query if everything went right, an empty optional otherwise
-
insert
Execute the given insert query- Parameters:
query- to execute, representing an insert query- Returns:
- true iff the query has been executed without problem
-
insertBatch
Insert the given values, using a batch insert and parameters for the query This is more efficient than looping over the parameters and executing each query at a time- Parameters:
query- the parameterized queryparameters- The query replacement parameters- Returns:
- true iff the queries have been executed without problem
-
copy
Copies CSV data using the supplied SQL copy statement.- Parameters:
sqlCopyQuery- sql query to copy csv data- Returns:
- true iff the copy succeeded
- Throws:
SQLException- iff an SQL exception occur
-
copyFromSTDIn
Copies CSV data from standard input using the supplied SQL copy statement.- Parameters:
sqlCopyQuery- sql query to copy csv datacsvFileName- csv file to copy- Returns:
- true iff the copy succeeded
- Throws:
SQLException- iff an SQL exception occur
-
execute
Executes the SQL statements stored in the supplied file.- Parameters:
sqlFilePath- path to a file containing SQL queries- Returns:
- true iff the copy succeeded
-