Class DatasourceOperations

java.lang.Object
org.apache.polaris.persistence.relational.jdbc.DatasourceOperations

public class DatasourceOperations extends Object
  • Constructor Details

  • Method Details

    • getDatabaseType

      public DatabaseType getDatabaseType()
    • executeScript

      public void executeScript(String scriptFilePath) throws SQLException
      Execute SQL script
      Parameters:
      scriptFilePath - : Path of SQL script.
      Throws:
      SQLException - : Exception while executing the script.
    • executeSelect

      public <T> List<T> executeSelect(@Nonnull QueryGenerator.PreparedQuery query, @Nonnull Converter<T> converterInstance) throws SQLException
      Executes SELECT Query and returns the results after applying a transformer
      Type Parameters:
      T - : Business entity class
      Parameters:
      query - : Query to executed
      converterInstance - : An instance of the type being selected, used to convert to a business entity like PolarisBaseEntity
      Returns:
      The list of results yielded by the query
      Throws:
      SQLException - : Exception during the query execution.
    • executeSelectOverStream

      public <T> void executeSelectOverStream(@Nonnull QueryGenerator.PreparedQuery query, @Nonnull Converter<T> converterInstance, @Nonnull Consumer<Stream<T>> consumer) throws SQLException
      Executes SELECT Query and takes a consumer over the results. For callers that want more sophisticated control over how query results are handled.
      Type Parameters:
      T - : Entity class
      Parameters:
      query - : Query to executed
      converterInstance - : An entity of the type being selected
      consumer - : An function to consume the returned results
      Throws:
      SQLException - : Exception during the query execution.
    • executeUpdate

      public int executeUpdate(QueryGenerator.PreparedQuery preparedQuery) throws SQLException
      Executes the UPDATE or INSERT Query
      Parameters:
      preparedQuery - : query to be executed
      Returns:
      : Number of rows modified / inserted.
      Throws:
      SQLException - : Exception during Query Execution.
    • runWithinTransaction

      public void runWithinTransaction(DatasourceOperations.TransactionCallback callback) throws SQLException
      Transaction callback to be executed.
      Parameters:
      callback - : TransactionCallback to be executed within transaction
      Throws:
      SQLException - : Exception caught during transaction execution.
    • execute

      public Integer execute(Connection connection, QueryGenerator.PreparedQuery preparedQuery) throws SQLException
      Throws:
      SQLException
    • isConstraintViolation

      public boolean isConstraintViolation(SQLException e)