Class ScriptExecutorTool


  • public class ScriptExecutorTool
    extends Object
    Execute given SQL script or single statements separated by given delimiter. Delimiter is ';' by default.
    Author:
    M. Dahm

    © 2012-2034 akquinet tech@spree

    • Field Detail

      • DEFAULT_ENCODING

        public static final String DEFAULT_ENCODING
    • Method Detail

      • executeFileScript

        public void executeFileScript​(String connectorId,
                                      String resourceName)
                               throws SQLException
        Read SQL from file somewhere on class path. Each statement (not line!) must end with a ';'
        Throws:
        SQLException
      • executeFileScript

        public void executeFileScript​(String connectorId,
                                      boolean updateSchema,
                                      boolean prepareTargetConnection,
                                      String resourceName)
                               throws SQLException
        Read SQL from file somewhere on class path. Each statement (not line!) must end with a ';'
        Throws:
        SQLException
      • executeScript

        public void executeScript​(String connectorId,
                                  String... lines)
                           throws SQLException
        Execute given lines of SQL. Each statement (not line!) must end with a ';'
        Throws:
        SQLException
      • executeScript

        public void executeScript​(String connectorId,
                                  boolean updateSchema,
                                  boolean prepareTargetConnection,
                                  String... lines)
                           throws SQLException
        Execute given lines of SQL. Each statement (not line!) must end with a ';'
        Throws:
        SQLException
      • executeScript

        public void executeScript​(String connectorId,
                                  List<String> lines)
                           throws SQLException
        Execute given lines of SQL. Each statement (not line!) must with a ';'
        Throws:
        SQLException
      • executeScript

        public void executeScript​(String connectorId,
                                  boolean scriptUpdatesSchema,
                                  boolean prepareTargetConnection,
                                  List<String> lines)
                           throws SQLException
        Execute given lines of SQL. Each statement (not line!) must end with a ';'
        Parameters:
        connectorId -
        scriptUpdatesSchema - The script alters the schema, scheme information needs to be reloaded
        prepareTargetConnection - the target connection is initialized using the appropriate TargetDatabaseConfiguration
        lines - SQL statements ending with ';'
        Throws:
        SQLException
      • executeQuery

        public List<Map<String,​Object>> executeQuery​(String connectorId,
                                                           String sql)
                                                    throws SQLException
        Execute query (i.e. SELECT...) and return the result set as a list of Maps where the key is the column name and the value the respective data.
        Throws:
        SQLException
      • executeQuery

        public List<Map<String,​Object>> executeQuery​(Connection connection,
                                                           String sql)
                                                    throws SQLException
        Execute query (i.e. SELECT...) and return the result set as a list of Maps where the key is the upper case column name and the value is the respective data of the column.
        Throws:
        SQLException