类 ResourceDatabasePopulator

    • 构造器详细资料

      • ResourceDatabasePopulator

        public ResourceDatabasePopulator()
        Construct a new ResourceDatabasePopulator with default settings.
        从以下版本开始:
        4.0.3
      • ResourceDatabasePopulator

        public ResourceDatabasePopulator​(Resource... scripts)
        Construct a new ResourceDatabasePopulator with default settings for the supplied scripts.
        参数:
        scripts - the scripts to execute to initialize or clean up the database (never null)
        从以下版本开始:
        4.0.3
      • ResourceDatabasePopulator

        public ResourceDatabasePopulator​(boolean continueOnError,
                                         boolean ignoreFailedDrops,
                                         String sqlScriptEncoding,
                                         Resource... scripts)
        Construct a new ResourceDatabasePopulator with the supplied values.
        参数:
        continueOnError - flag to indicate that all failures in SQL should be logged but not cause a failure
        ignoreFailedDrops - flag to indicate that a failed SQL DROP statement can be ignored
        sqlScriptEncoding - the encoding for the supplied SQL scripts; may be null or empty to indicate platform encoding
        scripts - the scripts to execute to initialize or clean up the database (never null)
        从以下版本开始:
        4.0.3
    • 方法详细资料

      • addScript

        public void addScript​(Resource script)
        Add a script to execute to initialize or clean up the database.
        参数:
        script - the path to an SQL script (never null)
      • addScripts

        public void addScripts​(Resource... scripts)
        Add multiple scripts to execute to initialize or clean up the database.
        参数:
        scripts - the scripts to execute (never null)
      • setScripts

        public void setScripts​(Resource... scripts)
        Set the scripts to execute to initialize or clean up the database, replacing any previously added scripts.
        参数:
        scripts - the scripts to execute (never null)
      • setSqlScriptEncoding

        public void setSqlScriptEncoding​(String sqlScriptEncoding)
        Specify the encoding for the configured SQL scripts, if different from the platform encoding.
        参数:
        sqlScriptEncoding - the encoding used in scripts; may be null or empty to indicate platform encoding
        另请参阅:
        addScript(Resource)
      • setSeparator

        public void setSeparator​(String separator)
        Specify the statement separator, if a custom one.

        Defaults to ";" if not specified and falls back to "\n" as a last resort; may be set to ScriptUtils.EOF_STATEMENT_SEPARATOR to signal that each script contains a single statement without a separator.

        参数:
        separator - the script statement separator
      • setCommentPrefix

        public void setCommentPrefix​(String commentPrefix)
        Set the prefix that identifies single-line comments within the SQL scripts.

        Defaults to "--".

        参数:
        commentPrefix - the prefix for single-line comments
      • setContinueOnError

        public void setContinueOnError​(boolean continueOnError)
        Flag to indicate that all failures in SQL should be logged but not cause a failure.

        Defaults to false.

        参数:
        continueOnError - true if script execution should continue on error
      • setIgnoreFailedDrops

        public void setIgnoreFailedDrops​(boolean ignoreFailedDrops)
        Flag to indicate that a failed SQL DROP statement can be ignored.

        This is useful for a non-embedded database whose SQL dialect does not support an IF EXISTS clause in a DROP statement.

        The default is false so that if the populator runs accidentally, it will fail fast if a script starts with a DROP statement.

        参数:
        ignoreFailedDrops - true if failed drop statements should be ignored