Interface DatabaseEngine
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractDatabaseEngine,CockroachDBEngine,DB2Engine,H2Engine,MySqlEngine,OracleEngine,PostgreSqlEngine,SqlServerEngine
public interface DatabaseEngine extends AutoCloseable
Interface with the specific database implementation. Provides methods to query and manipulate database objects.- Since:
- 2.0.0
- Author:
- Rui Vilao (rui.vilao@feedzai.com)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidaddBatch(String name, EntityEntry entry)Adds an entry to the batch.voidaddEntity(DbEntity entity)Adds an entity to the engine.voidbeginTransaction()Starts a transaction.booleancheckConnection()Checks if the connection is alive.booleancheckConnection(boolean forceReconnect)Checks if the connection is alive.voidclearParameters(String name)Clears the prepared statement parameters.voidclose()Closes the connection to the database.StringcommentCharacter()voidcommit()Commits the current transaction.booleancontainsEntity(String name)Returns if the current engine contains the entity.AbstractBatchcreateBatch(int batchSize, long batchTimeout)Creates a new batch that periodically flushes a batch.AbstractBatchcreateBatch(int batchSize, long batchTimeout, String batchName)Creates a new batch that periodically flushes a batch.AbstractBatchcreateBatch(int batchSize, long batchTimeout, String batchName, FailureListener failureListener)Deprecated.UsecreateBatch(int, long, String, BatchListener)instead.default AbstractBatchcreateBatch(int batchSize, long batchTimeout, String batchName, BatchListener batchListener)Creates a new batch that periodically flushes a batch.voidcreatePreparedStatement(String name, Expression query)Creates a prepared statement.voidcreatePreparedStatement(String name, Expression query, int timeout)Creates a prepared statement.voidcreatePreparedStatement(String name, String query)Creates a prepared statement.voidcreatePreparedStatement(String name, String query, int timeout)Creates a prepared statement.voiddropEntity(DbEntity entity)Drops everything that belongs to the entity.voiddropEntity(String entity)Drops an entity.voiddropView(String view)Drops a view.DatabaseEngineduplicate(Properties mergeProperties, boolean copyEntities)Duplicates a connection.StringescapeCharacter()voidexecutePS(String name)Executes the specified prepared statement.IntegerexecutePSUpdate(String name)Executes update on the specified prepared statement.intexecuteUpdate(Expression query)Executes the given update.intexecuteUpdate(String query)Executes a native query.voidflush()Flushes the batches for all the registered entities.ConnectiongetConnection()Checks if the connection is available and returns it.DialectgetDialect()Gets the dialect being used.Map<String,DbEntityType>getEntities()Gets the database entities for the current schema.Map<String,DbEntityType>getEntities(String schemaPattern)Gets the database entities for the specified schema.Map<String,DbColumnType>getMetadata(String tableNamePattern)Gets the table metadata (table must be in the current schema).Map<String,DbColumnType>getMetadata(String schemaPattern, String tableNamePattern)Gets the table metadata (table must be in the current schema).PdbPropertiesgetProperties()Gets the properties in use.ResultIteratorgetPSIterator(String name)Creates an iterator for thePreparedStatementbound to the given name.ResultIteratorgetPSIterator(String name, int fetchSize)Creates an iterator for thePreparedStatementbound to the given name.List<Map<String,ResultColumn>>getPSResultSet(String name)Gets the result set of the specified prepared statement.Map<String,DbColumnType>getQueryMetadata(Expression query)Gets the query metadata.Map<String,DbColumnType>getQueryMetadata(String query)Gets the query metadata.booleanisStringAggDistinctCapable()Checks if the engine supports using DISTINCT inside a string aggregation.booleanisTransactionActive()Checks if a transaction is active.ResultIteratoriterator(Expression query)Creates an iterator for the given SQL expression.ResultIteratoriterator(Expression query, int fetchSize)Creates an iterator for the given SQL expression.default ResultIteratoriterator(Expression query, int fetchSize, int readTimeoutOverride)Creates an iterator for the given SQL expression overriding the configured query timeout (seePdbProperties.getSelectQueryTimeout()) if the underlying engine supports query timeouts.ResultIteratoriterator(String query)Creates an iterator for the given SQL sentence.ResultIteratoriterator(String query, int fetchSize)Creates an iterator for the given SQL sentence.default ResultIteratoriterator(String query, int fetchSize, int readTimeoutOverride)Creates an iterator for the given SQL sentence overriding the configured query timeout (seePdbProperties.getSelectQueryTimeout()) if the underlying engine supports query timeouts.voidloadEntity(DbEntity entity)Loads an entity into the engine.Longpersist(String name, EntityEntry entry)Persists a given entry.Longpersist(String name, EntityEntry entry, boolean useAutoInc)Persists a given entry.booleanpreparedStatementExists(String name)Checks if there's a prepared statement with the given name.List<Map<String,ResultColumn>>query(Expression query)Executes the given query.default List<Map<String,ResultColumn>>query(Expression query, int readTimeoutOverride)Executes the given query overriding the configured query timeout (seePdbProperties.getSelectQueryTimeout()) if the underlying engine supports query timeouts.List<Map<String,ResultColumn>>query(String query)Executes the given native query.default List<Map<String,ResultColumn>>query(String query, int readTimeoutOverride)Executes the given native query overriding the configured query timeout (seePdbProperties.getSelectQueryTimeout()if the underlying engine supports query timeouts.DbEntityremoveEntity(String name)Removes the entity given the name.voidremovePreparedStatement(String name)Removes the given prepared statement.voidrollback()Rolls back a transaction.voidsetExceptionHandler(ExceptionHandler eh)Sets the given exception handler in the engine.voidsetParameter(String name, int index, Object param)Sets the parameter on the specified index.voidsetParameter(String name, int index, Object param, DbColumnType paramType)Sets the parameter on the specified index given its type.voidsetParameters(String name, Object... params)Sets the parameters on the specified prepared statement.Stringtranslate(Expression query)Translates the given expression to the current dialect.voidupdateEntity(DbEntity entity)Updates an entity in the engine.
-
-
-
Method Detail
-
close
void close()
Closes the connection to the database.- Specified by:
closein interfaceAutoCloseable
-
beginTransaction
void beginTransaction() throws DatabaseEngineRuntimeExceptionStarts a transaction. Doing this will set auto commit to false (Connection.getAutoCommit()).- Throws:
DatabaseEngineRuntimeException- If something goes wrong while beginning transaction.
-
addEntity
void addEntity(DbEntity entity) throws DatabaseEngineException
Adds an entity to the engine. It will create tables and everything necessary so persistence can work.- Parameters:
entity- The entity to add.- Throws:
DatabaseEngineException- If something goes wrong while creating the structures.
-
loadEntity
void loadEntity(DbEntity entity) throws DatabaseEngineException
Loads an entity into the engine.No DDL commands will be executed, only prepared statements will be created in order to
persistdata into the entities.- Parameters:
entity- The entity to load into the connection.- Throws:
DatabaseEngineException- If something goes wrong while loading the entity.- Since:
- 2.1.2
-
updateEntity
void updateEntity(DbEntity entity) throws DatabaseEngineException
Updates an entity in the engine.
If the entity does not exists in the instance, the method
addEntity(com.feedzai.commons.sql.abstraction.ddl.DbEntity)will be invoked.The engine will compare the entity with the
getMetadata(String)information and update the schema of the table.ATTENTION: This method will only add new columns or drop removed columns in the database table. Primary Keys, Foreign Keys, Indexes and column types changes will not be updated.
- Parameters:
entity- The entity to update.- Throws:
DatabaseEngineException- If something goes wrong while updating the entity.- Since:
- 2.0.0
-
removeEntity
DbEntity removeEntity(String name)
Removes the entity given the name. If the schema is drop-create then the entity will be dropped.- Parameters:
name- The name of the entity to remove.- Returns:
- The entity removed or null if there's no entity with the given name.
-
containsEntity
boolean containsEntity(String name)
Returns if the current engine contains the entity.- Parameters:
name- The entity name.- Returns:
- True if the engine has the entity, false otherwise.
-
dropEntity
void dropEntity(String entity) throws DatabaseEngineException
Drops an entity.- Parameters:
entity- The entity name.- Throws:
DatabaseEngineException- If something goes wrong while dropping the entity.
-
dropEntity
void dropEntity(DbEntity entity) throws DatabaseEngineException
Drops everything that belongs to the entity.- Parameters:
entity- The entity.- Throws:
DatabaseEngineException- If something goes wrong while dropping the structures.
-
dropView
void dropView(String view) throws DatabaseEngineException
Drops a view.- Parameters:
view- The view name.- Throws:
DatabaseEngineException- If something goes wrong while dropping the view.- Since:
- 2.6.0
-
persist
Long persist(String name, EntityEntry entry) throws DatabaseEngineException
Persists a given entry. Persisting a query implies executing the statement.If you are inside of an explicit transaction, changes will only be visible upon explicit commit, otherwise a commit will immediately take place.
- Parameters:
name- The entity name.entry- The entry to persist.- Returns:
- The ID of the auto generated value,
nullif there's no auto generated value. - Throws:
DatabaseEngineException- If something goes wrong while persisting data.
-
persist
Long persist(String name, EntityEntry entry, boolean useAutoInc) throws DatabaseEngineException
Persists a given entry. Persisting a query implies executing the statement. If define useAutoInc as false, PDB will disable the auto increments for the current insert and advance the sequences if needed.
If you are inside of an explicit transaction, changes will only be visible upon explicit commit, otherwise a commit will immediately take place.
- Parameters:
name- The entity name.entry- The entry to persist.useAutoInc- Use or not the autoinc.- Returns:
- The ID of the auto generated value,
nullif there's no auto generated value. - Throws:
DatabaseEngineException- If something goes wrong while persisting data.
-
flush
void flush() throws DatabaseEngineExceptionFlushes the batches for all the registered entities.- Throws:
DatabaseEngineException- If something goes wrong while persisting data.
-
commit
void commit() throws DatabaseEngineRuntimeExceptionCommits the current transaction. You should only call this method if you've previously calledbeginTransaction().- Throws:
DatabaseEngineRuntimeException- If something goes wrong while committing transaction.
-
rollback
void rollback() throws DatabaseEngineRuntimeExceptionRolls back a transaction. You should only call this method if you've previously calledbeginTransaction().- Throws:
DatabaseEngineRuntimeException- If the rollback fails.
-
isTransactionActive
boolean isTransactionActive() throws DatabaseEngineRuntimeExceptionChecks if a transaction is active.- Returns:
trueif the transaction is active,falseotherwise.- Throws:
DatabaseEngineRuntimeException- If the access to the database fails.
-
executeUpdate
int executeUpdate(String query) throws DatabaseEngineException
Executes a native query.- Parameters:
query- The query to execute.- Returns:
- The number of rows updated.
- Throws:
DatabaseEngineException- If something goes wrong executing the native query.
-
executeUpdate
int executeUpdate(Expression query) throws DatabaseEngineException
Executes the given update.- Parameters:
query- The update to execute.- Throws:
DatabaseEngineException- If something goes wrong executing the update.
-
translate
String translate(Expression query)
Translates the given expression to the current dialect.- Parameters:
query- The query to translate.- Returns:
- The translation result.
-
getDialect
Dialect getDialect()
Gets the dialect being used.- Returns:
- The dialect being used.
-
createBatch
AbstractBatch createBatch(int batchSize, long batchTimeout)
Creates a new batch that periodically flushes a batch. A flush will also occur when the maximum number of statements in the batch is reached. Please be sure to callAbstractBatch.destroy()before closing the session with the database.- Parameters:
batchSize- The batch size.batchTimeout- If inserts do not occur after the specified time, a flush will be performed.- Returns:
- The batch.
-
createBatch
AbstractBatch createBatch(int batchSize, long batchTimeout, String batchName)
Creates a new batch that periodically flushes a batch. A flush will also occur when the maximum number of statements in the batch is reached. Please be sure to callAbstractBatch.destroy()before closing the session with the database.- Parameters:
batchSize- The batch size.batchTimeout- If inserts do not occur after the specified time, a flush will be performed.batchName- The batch name.- Returns:
- The batch.
-
createBatch
@Deprecated AbstractBatch createBatch(int batchSize, long batchTimeout, String batchName, FailureListener failureListener)
Deprecated.UsecreateBatch(int, long, String, BatchListener)instead.Creates a new batch that periodically flushes a batch. A flush will also occur when the maximum number of statements in the batch is reached.If desired you may provide an
Please be sure to callOptionalFailureListenerthat will be invoked when the batch fails to persist data.AbstractBatch.destroy()before closing the session with the database.- Parameters:
batchSize- The batch size.batchTimeout- If inserts do not occur after the specified time, a flush will be performed.batchName- The batch name.failureListener- Failure listener to execute custom behavior when the batch fails to persist.- Returns:
- The batch.
- Since:
- 2.1.11
-
createBatch
default AbstractBatch createBatch(int batchSize, long batchTimeout, String batchName, @Nullable BatchListener batchListener)
Creates a new batch that periodically flushes a batch. A flush will also occur when the maximum number of statements in the batch is reached.If desired you may provide a
Please be sure to callBatchListenerthat will be invoked when a batch operation fails or succeeds to persist data.AbstractBatch.destroy()before closing the session with the database.- Parameters:
batchSize- The batch size.batchTimeout- If inserts do not occur after the specified time, a flush will be performed.batchName- The batch name.batchListener- Batch listener to execute custom behavior when the batch fails or succeeds to persist.- Returns:
- The batch.
- Since:
- 2.8.1
-
checkConnection
boolean checkConnection(boolean forceReconnect)
Checks if the connection is alive.- Parameters:
forceReconnect-trueto force the connection in case of failure,falseotherwise.- Returns:
trueif the connection is valid, false otherwise.
-
checkConnection
boolean checkConnection()
Checks if the connection is alive.- Returns:
trueif the connection is valid,falseotherwise.
-
addBatch
void addBatch(String name, EntityEntry entry) throws DatabaseEngineException
Adds an entry to the batch.- Parameters:
name- The entity name.entry- The entry to persist.- Throws:
DatabaseEngineException- If something goes wrong while persisting data.
-
query
List<Map<String,ResultColumn>> query(Expression query) throws DatabaseEngineException
Executes the given query.- Parameters:
query- The query to execute.- Throws:
DatabaseEngineException- If something goes wrong executing the query.
-
query
default List<Map<String,ResultColumn>> query(Expression query, int readTimeoutOverride) throws DatabaseEngineException
Executes the given query overriding the configured query timeout (seePdbProperties.getSelectQueryTimeout()) if the underlying engine supports query timeouts.- Parameters:
query- The query to execute.readTimeoutOverride- The query timeout to use.- Throws:
DatabaseEngineException- If something goes wrong executing the query.
-
query
List<Map<String,ResultColumn>> query(String query) throws DatabaseEngineException
Executes the given native query.- Parameters:
query- The query to execute.- Throws:
DatabaseEngineException- If something goes wrong executing the query.
-
query
default List<Map<String,ResultColumn>> query(String query, int readTimeoutOverride) throws DatabaseEngineException
Executes the given native query overriding the configured query timeout (seePdbProperties.getSelectQueryTimeout()if the underlying engine supports query timeouts.- Parameters:
query- The query to execute.readTimeoutOverride- The query timeout to use.- Throws:
DatabaseEngineException- If something goes wrong executing the query.
-
getEntities
Map<String,DbEntityType> getEntities() throws DatabaseEngineException
Gets the database entities for the current schema.- Returns:
- The list of database entities and types (tables, views, and so on).
- Throws:
DatabaseEngineException- If something occurs getting the existing tables.
-
getEntities
Map<String,DbEntityType> getEntities(String schemaPattern) throws DatabaseEngineException
Gets the database entities for the specified schema.- Parameters:
schemaPattern- A schema name pattern; must match the schema name as it is stored in the database;""retrieves those without a schema;nullmeans that the schema name should not be used to narrow the search.- Returns:
- The list of database entities and types (tables, views, and so on).
- Throws:
DatabaseEngineException- If something occurs getting the existing tables.- Since:
- 2.1.13
-
getMetadata
Map<String,DbColumnType> getMetadata(String tableNamePattern) throws DatabaseEngineException
Gets the table metadata (table must be in the current schema).- Parameters:
tableNamePattern- A table name pattern; must match the table name as it is stored in the database.- Returns:
- A representation of the table columns and types.
- Throws:
DatabaseEngineException- If something occurs getting the metadata.
-
getMetadata
Map<String,DbColumnType> getMetadata(String schemaPattern, String tableNamePattern) throws DatabaseEngineException
Gets the table metadata (table must be in the current schema).- Parameters:
tableNamePattern- A table name pattern; must match the table name as it is stored in the database.schemaPattern- A schema name pattern; must match the schema name as it is stored in the database;""retrieves those without a schema;nullmeans that the schema name should not be used to narrow the search.- Returns:
- A representation of the table columns and types.
- Throws:
DatabaseEngineException- If something occurs getting the metadata.- Since:
- 2.1.13
-
getQueryMetadata
Map<String,DbColumnType> getQueryMetadata(Expression query) throws DatabaseEngineException
Gets the query metadata.- Parameters:
query- The query to retrieve the metadata from.- Returns:
- A representation of the table columns and types.
- Throws:
DatabaseEngineException- If something occurs getting the metadata.
-
getQueryMetadata
Map<String,DbColumnType> getQueryMetadata(String query) throws DatabaseEngineException
Gets the query metadata.- Parameters:
query- The query to retrieve the metadata from.- Returns:
- A representation of the table columns and types.
- Throws:
DatabaseEngineException- If something occurs getting the metadata.
-
duplicate
DatabaseEngine duplicate(Properties mergeProperties, boolean copyEntities) throws DuplicateEngineException
Duplicates a connection.- Parameters:
mergeProperties- Merge properties with the ones already existing.copyEntities-trueto include the entities in the new connection,falseotherwise.- Returns:
- The new connection.
- Throws:
DuplicateEngineException- If policy is set to other than 'create' or 'none' or duplication fails for some reason.
-
getProperties
PdbProperties getProperties()
Gets the properties in use.- Returns:
- A clone of the properties in use.
-
createPreparedStatement
void createPreparedStatement(String name, Expression query) throws NameAlreadyExistsException, DatabaseEngineException
Creates a prepared statement.- Parameters:
name- The prepared statement name.query- The query.- Throws:
NameAlreadyExistsException- If the name already exists.DatabaseEngineException- If something goes wrong creating the statement.
-
createPreparedStatement
void createPreparedStatement(String name, String query) throws NameAlreadyExistsException, DatabaseEngineException
Creates a prepared statement.- Parameters:
name- The prepared statement name.query- The query.- Throws:
NameAlreadyExistsException- If the name already exists.DatabaseEngineException- If something goes wrong creating the statement.
-
createPreparedStatement
void createPreparedStatement(String name, Expression query, int timeout) throws NameAlreadyExistsException, DatabaseEngineException
Creates a prepared statement.- Parameters:
name- The prepared statement name.query- The query.timeout- The timeout (in seconds) for the query to execute.- Throws:
NameAlreadyExistsException- If the name already exists.DatabaseEngineException- If something goes wrong creating the statement.
-
createPreparedStatement
void createPreparedStatement(String name, String query, int timeout) throws NameAlreadyExistsException, DatabaseEngineException
Creates a prepared statement.- Parameters:
name- The prepared statement name.query- The query.timeout- The timeout (in seconds) for the query to execute.- Throws:
NameAlreadyExistsException- If the name already exists.DatabaseEngineException- If something goes wrong creating the statement.
-
removePreparedStatement
void removePreparedStatement(String name)
Removes the given prepared statement.- Parameters:
name- The prepared statement name.
-
getPSResultSet
List<Map<String,ResultColumn>> getPSResultSet(String name) throws DatabaseEngineException, ConnectionResetException
Gets the result set of the specified prepared statement.- Parameters:
name- The prepared statement name.- Returns:
- The result.
- Throws:
DatabaseEngineException- If something occurs getting the result.ConnectionResetException
-
setParameters
void setParameters(String name, Object... params) throws DatabaseEngineException, ConnectionResetException
Sets the parameters on the specified prepared statement.- Parameters:
name- The prepared statement name.params- The parameters to set.- Throws:
DatabaseEngineException- If something occurs setting the parameters.ConnectionResetException- If the connection was reset while trying to set parameters.
-
setParameter
void setParameter(String name, int index, Object param) throws DatabaseEngineException, ConnectionResetException
Sets the parameter on the specified index.- Parameters:
name- The prepared statement name.index- The index to set.param- The parameter to set.- Throws:
DatabaseEngineException- If something occurs setting the parameters.ConnectionResetException- If the connection was reset while trying to set the parameter.
-
setParameter
void setParameter(String name, int index, Object param, DbColumnType paramType) throws DatabaseEngineException, ConnectionResetException
Sets the parameter on the specified index given its type. This is for situations where the java type of the parameter alone is not enough to determine the corresponding database type; for example, Strings can be used to represent both actual Strings and Json values, so if we have an update statement that updates a json column we need to specify that the bind parameter is of type json.- Parameters:
name- The prepared statement name.index- The index to set.param- The parameter to set.paramType- The type of the parameter being set.- Throws:
DatabaseEngineException- If something occurs setting the parameters.ConnectionResetException- If the connection was reset while trying to set the parameter.- Since:
- 2.1.5
-
executePS
void executePS(String name) throws DatabaseEngineException, ConnectionResetException
Executes the specified prepared statement.- Parameters:
name- The prepared statement name.- Throws:
DatabaseEngineException- If something goes wrong while executing.ConnectionResetException- If the connection is down and reestablishment occurs. If this happens, the user must reset the parameters and re-execute the query.
-
clearParameters
void clearParameters(String name) throws DatabaseEngineException, ConnectionResetException
Clears the prepared statement parameters.- Parameters:
name- The prepared statement name.- Throws:
DatabaseEngineException- If something occurs while clearing the parameters.ConnectionResetException- If the connection was reset.
-
preparedStatementExists
boolean preparedStatementExists(String name)
Checks if there's a prepared statement with the given name.- Parameters:
name- The name to test.- Returns:
trueif it exists,falseotherwise.
-
executePSUpdate
Integer executePSUpdate(String name) throws DatabaseEngineException, ConnectionResetException
Executes update on the specified prepared statement.- Parameters:
name- The prepared statement name.- Throws:
DatabaseEngineException- If the prepared statement does not exist or something goes wrong while executing.ConnectionResetException- If the connection is down and reestablishment occurs. If this happens, the user must reset the parameters and re-execute the query.
-
commentCharacter
String commentCharacter()
- Returns:
- The comment character of this engine implementation.
-
escapeCharacter
String escapeCharacter()
- Returns:
- The escape character of this engine implementation.
-
getConnection
Connection getConnection() throws RetryLimitExceededException, InterruptedException, RecoveryException
Checks if the connection is available and returns it. If the connection is not available, it tries to reconnect (the number of times defined in the properties with the delay there specified).- Returns:
- The connection.
- Throws:
RetryLimitExceededException- If the retry limit is exceeded.InterruptedException- If the thread is interrupted during reconnection.RecoveryException
-
iterator
ResultIterator iterator(String query) throws DatabaseEngineException
Creates an iterator for the given SQL sentence.- Parameters:
query- The query.- Returns:
- An iterator for the results of the given SQL query.
- Throws:
DatabaseEngineException- If a database access error occurs.
-
iterator
ResultIterator iterator(Expression query) throws DatabaseEngineException
Creates an iterator for the given SQL expression.- Parameters:
query- The expression that represents the query.- Returns:
- An iterator for the results of the given SQL expression.
- Throws:
DatabaseEngineException- If a database access error occurs.
-
iterator
ResultIterator iterator(String query, int fetchSize) throws DatabaseEngineException
Creates an iterator for the given SQL sentence.- Parameters:
query- The query.fetchSize- The number of rows to fetch each time.- Returns:
- An iterator for the results of the given SQL query.
- Throws:
DatabaseEngineException- If a database access error occurs.
-
iterator
default ResultIterator iterator(String query, int fetchSize, int readTimeoutOverride) throws DatabaseEngineException
Creates an iterator for the given SQL sentence overriding the configured query timeout (seePdbProperties.getSelectQueryTimeout()) if the underlying engine supports query timeouts.- Parameters:
query- The query.fetchSize- The number of rows to fetch each time.readTimeoutOverride- The query timeout to use.- Returns:
- An iterator for the results of the given SQL query.
- Throws:
DatabaseEngineException- If a database access error occurs.
-
iterator
ResultIterator iterator(Expression query, int fetchSize) throws DatabaseEngineException
Creates an iterator for the given SQL expression.- Parameters:
query- The expression that represents the query.fetchSize- The number of rows to fetch each time.- Returns:
- An iterator for the results of the given SQL expression.
- Throws:
DatabaseEngineException- If a database access error occurs.
-
iterator
default ResultIterator iterator(Expression query, int fetchSize, int readTimeoutOverride) throws DatabaseEngineException
Creates an iterator for the given SQL expression overriding the configured query timeout (seePdbProperties.getSelectQueryTimeout()) if the underlying engine supports query timeouts.- Parameters:
query- The expression that represents the query.fetchSize- The number of rows to fetch each time.readTimeoutOverride- The query timeout to use.- Returns:
- An iterator for the results of the given SQL expression.
- Throws:
DatabaseEngineException- If a database access error occurs.
-
getPSIterator
ResultIterator getPSIterator(String name) throws DatabaseEngineException, ConnectionResetException
Creates an iterator for thePreparedStatementbound to the given name.- Parameters:
name- The name of the prepared statement.- Returns:
- An iterator for the results of the prepared statement of the given name.
- Throws:
DatabaseEngineException- If a database access error occurs.ConnectionResetException
-
getPSIterator
ResultIterator getPSIterator(String name, int fetchSize) throws DatabaseEngineException, ConnectionResetException
Creates an iterator for thePreparedStatementbound to the given name.- Parameters:
name- The name of the prepared statement.fetchSize- The number of rows to fetch each time.- Returns:
- An iterator for the results of the prepared statement of the given name.
- Throws:
DatabaseEngineException- If a database access error occurs.ConnectionResetException
-
setExceptionHandler
void setExceptionHandler(ExceptionHandler eh)
Sets the given exception handler in the engine.- Parameters:
eh- The reference for exception callbacks.
-
isStringAggDistinctCapable
boolean isStringAggDistinctCapable()
Checks if the engine supports using DISTINCT inside a string aggregation.- Returns:
- true if the engine supports using DISTINCT inside a string aggregation, false otherwise.
-
-