Class ExecuteSQL

java.lang.Object
ru.bgcrm.dao.CommonDAO
org.bgerp.app.dist.inst.call.ExecuteSQL
All Implemented Interfaces:
InstallationCall

public class ExecuteSQL extends CommonDAO implements InstallationCall
Executer of SQL queries for updating DB structure. Running as InstallationCall and also directly.
  • Constructor Details

    • ExecuteSQL

      public ExecuteSQL()
      Default constructor
  • Method Details

    • clearHashes

      public static void clearHashes() throws SQLException
      Clears all stored applied-update hashes.
      Throws:
      SQLException - on a database error
    • skipHash

      public static void skipHash(String hash) throws SQLException
      Marks a query hash as applied so the query is skipped.
      Parameters:
      hash - query hash
      Throws:
      SQLException - on a database error
    • call

      public void call(Setup setup, File zip, String param) throws Exception
      Description copied from interface: InstallationCall
      Executes the call.
      Specified by:
      call in interface InstallationCall
      Parameters:
      setup - application setup
      zip - the module ZIP file
      param - call parameter from module.properties
      Throws:
      Exception - on a call error
    • call

      public void call(Connection con, String query) throws SQLException
      Executes multiline SQL script.
      Parameters:
      con - connection.
      query - SQL script, tokenized to commands by ;.
      Throws:
      SQLException - on a database error
    • doQuery

      protected void doQuery(Statement st, String query, boolean useHash, Set<String> existingHashes, Set<String> newHashes) throws SQLException
      Executes SQL query.
      Parameters:
      st - SQL statement, running the query.
      query - the query.
      useHash - use executed query hash to prevent re-execution.
      existingHashes - hashes of already applied queries.
      newHashes - set there added hash of executed query if it wasn't presented in hashes.
      Throws:
      SQLException - on a database error
    • getQueryHashes

      protected Set<String> getQueryHashes(Connection con) throws SQLException
      Loads applied query hashes.
      Parameters:
      con - SQL connection.
      Returns:
      set with hashes.
      Throws:
      SQLException - on a database error
    • addHashes

      protected void addHashes(Connection con, Set<String> hashes) throws SQLException
      Stores executed queries hashes.
      Parameters:
      con - SQL connection.
      hashes - set with hashes.
      Throws:
      SQLException - on a database error