Class JdbcExecutor
- java.lang.Object
-
- net.hydromatic.sqllogictest.executors.SqlTestExecutor
-
- net.hydromatic.sqllogictest.executors.SqlSltTestExecutor
-
- net.hydromatic.sqllogictest.executors.JdbcExecutor
-
- All Implemented Interfaces:
ICastable
- Direct Known Subclasses:
HsqldbExecutor,PostgresExecutor
public abstract class JdbcExecutor extends SqlSltTestExecutor
Base class for tests executors that use a JDBC connection to execute tests.
-
-
Constructor Summary
Constructors Constructor Description JdbcExecutor(OptionsParser.SuppliedOptions options, String dbUrl, String username, String password)Create an executor that uses JDBC to run tests.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseConnection()Close the connection to the databse.voiddropAllTables()voiddropAllViews()voidestablishConnection()Establish a JDBC connection to the database.TestStatisticsexecute(SltTestFile file, OptionsParser.SuppliedOptions options)Execute all the test in the specified file using this database.ConnectiongetConnection()Get the connection.voidstatement(SltSqlStatement statement)Execute the specified statement.booleanvalidate(SqlTestQuery query, ResultSet rs, SqlTestQueryOutputDescription description, TestStatistics statistics)Validate the result of the execution of a query.-
Methods inherited from class net.hydromatic.sqllogictest.executors.SqlTestExecutor
avoid
-
-
-
-
Field Detail
-
dbUrl
public final String dbUrl
URL for connecting to the databse.
-
-
Constructor Detail
-
JdbcExecutor
public JdbcExecutor(OptionsParser.SuppliedOptions options, String dbUrl, String username, String password)
Create an executor that uses JDBC to run tests.- Parameters:
options- Execution options.dbUrl- URL for the database.username- Name of database user.password- Password of database user.
-
-
Method Detail
-
getConnection
public Connection getConnection()
Get the connection. Throws if the connection has not been established.
-
statement
public void statement(SltSqlStatement statement) throws SQLException
Execute the specified statement.- Parameters:
statement- SQL statement to execute. Throws when a statement fails although it should pass.- Throws:
SQLException
-
validate
public boolean validate(SqlTestQuery query, ResultSet rs, SqlTestQueryOutputDescription description, TestStatistics statistics) throws SQLException, NoSuchAlgorithmException
Validate the result of the execution of a query. Returns 'true' if execution has to stop due to a validation failure.- Throws:
SQLExceptionNoSuchAlgorithmException
-
dropAllTables
public void dropAllTables() throws SQLException- Throws:
SQLException
-
dropAllViews
public void dropAllViews() throws SQLException- Throws:
SQLException
-
establishConnection
public void establishConnection() throws SQLExceptionEstablish a JDBC connection to the database.- Throws:
SQLException
-
closeConnection
public void closeConnection() throws SQLExceptionClose the connection to the databse.- Throws:
SQLException
-
execute
public TestStatistics execute(SltTestFile file, OptionsParser.SuppliedOptions options) throws SQLException
Execute all the test in the specified file using this database.- Specified by:
executein classSqlSltTestExecutor- Parameters:
file- File with tests.options- Options guiding the execution.- Returns:
- The statistics describing the tests executed.
- Throws:
SQLException
-
-