Mainly for internal use within the framework.
org.springframework.r2dbc.connection.init.ScriptUtils
| Modifier and Type | Field and Description |
|---|---|
| public static final String | DEFAULT_BLOCK_COMMENT_END_DELIMITER
Default end delimiter for block comments within SQL scripts: |
| public static final String | DEFAULT_BLOCK_COMMENT_START_DELIMITER
Default start delimiter for block comments within SQL scripts: |
| public static final String | DEFAULT_COMMENT_PREFIX
Default prefix for single-line comments within SQL scripts: |
| public static final String[] | DEFAULT_COMMENT_PREFIXES
Default prefixes for single-line comments within SQL scripts: |
| public static final String | DEFAULT_STATEMENT_SEPARATOR
Default statement separator within SQL scripts: |
| public static final String | EOF_STATEMENT_SEPARATOR
End of file (EOF) SQL statement separator: |
| public static final String | FALLBACK_STATEMENT_SEPARATOR
Fallback statement separator within SQL scripts: |
| private static final Log |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| pack-priv static boolean | containsStatementSeparator(EncodedResource
the resource from which the script was read, or resource, String null
if unknownthe SQL script to search within script, String the statement separator to search for separator, String[] the prefixes that identify single-line comments
(typically commentPrefixes, String "--")the start block comment delimiter
(typically blockCommentStartDelimiter, String "/*")the end block comment delimiter
(typically blockCommentEndDelimiter)"*/")Determine if the provided SQL script contains the specified statement separator. |
| public static void | executeSqlScript(Connection
the JDBC connection to use to execute the script; already
configured and ready to use connection, Resource the resource to load the SQL script from; encoded with the
current platform's default encoding resource)Execute the given SQL script using default settings for statement separators, comment delimiters, and exception handling flags. |
| public static void | executeSqlScript(Connection
the JDBC connection to use to execute the script; already
configured and ready to use connection, EncodedResource the resource (potentially associated with a specific encoding)
to load the SQL script from resource)Execute the given SQL script using default settings for statement separators, comment delimiters, and exception handling flags. |
| public static void | executeSqlScript(Connection
the JDBC connection to use to execute the script; already
configured and ready to use connection, EncodedResource the resource (potentially associated with a specific encoding)
to load the SQL script from resource, boolean whether to continue without throwing an exception
in the event of an error continueOnError, boolean whether to continue in the event of specifically
an error on a ignoreFailedDrops, String DROP statementthe prefix that identifies single-line comments in the
SQL script (typically "--") commentPrefix, String the script statement separator; defaults to
; if not specified and falls back to
as a last resort; may be set to
^^^ END OF SCRIPT ^^^ to signal that the script contains a
single statement without a separator separator, String the start block comment delimiter blockCommentStartDelimiter, String the end block comment delimiter blockCommentEndDelimiter)Execute the given SQL script. |
| public static void | executeSqlScript(Connection
the JDBC connection to use to execute the script; already
configured and ready to use connection, EncodedResource the resource (potentially associated with a specific encoding)
to load the SQL script from resource, boolean whether to continue without throwing an exception
in the event of an error continueOnError, boolean whether to continue in the event of specifically
an error on a ignoreFailedDrops, String[] DROP statementthe prefixes that identify single-line comments in the
SQL script (typically "--") commentPrefixes, String the script statement separator; defaults to
; if not specified and falls back to
as a last resort; may be set to
^^^ END OF SCRIPT ^^^ to signal that the script contains a
single statement without a separator separator, String the start block comment delimiter blockCommentStartDelimiter, String the end block comment delimiter blockCommentEndDelimiter)Execute the given SQL script. |
| pack-priv static String | Returns: aString containing the script linesthe resource, String EncodedResource containing the script
to be processedthe statement separator in the SQL script (typically ";") separator, String[] the prefixes that identify comments in the SQL script
(typically "--") commentPrefixes, String the end block comment delimiter blockCommentEndDelimiter)Read a script from the provided resource, using the supplied comment prefixes
and statement separator, and build a |
| private static String | readScript(LineNumberReader lineNumberReader, String[] commentPrefixes, String separator, String blockCommentEndDelimiter)
|
| pack-priv static void | splitSqlScript(EncodedResource
the resource from which the script was read resource, String the SQL script script, String text separating each statement
(typically a ';' or newline character) separator, String[] the prefixes that identify SQL line comments
(typically "--") commentPrefixes, String the start block comment delimiter;
never blockCommentStartDelimiter, String null or emptythe end block comment delimiter;
never blockCommentEndDelimiter, List<String> null or emptythe list that will contain the individual statements statements)Split an SQL script into separate statements delimited by the provided separator string. |
| private static boolean |
| DEFAULT_BLOCK_COMMENT_END_DELIMITER | back to summary |
|---|---|
| public static final String DEFAULT_BLOCK_COMMENT_END_DELIMITER Default end delimiter for block comments within SQL scripts: | |
| DEFAULT_BLOCK_COMMENT_START_DELIMITER | back to summary |
|---|---|
| public static final String DEFAULT_BLOCK_COMMENT_START_DELIMITER Default start delimiter for block comments within SQL scripts: | |
| DEFAULT_COMMENT_PREFIX | back to summary |
|---|---|
| public static final String DEFAULT_COMMENT_PREFIX Default prefix for single-line comments within SQL scripts: | |
| DEFAULT_COMMENT_PREFIXES | back to summary |
|---|---|
| public static final String[] DEFAULT_COMMENT_PREFIXES Default prefixes for single-line comments within SQL scripts:
| |
| DEFAULT_STATEMENT_SEPARATOR | back to summary |
|---|---|
| public static final String DEFAULT_STATEMENT_SEPARATOR Default statement separator within SQL scripts: | |
| EOF_STATEMENT_SEPARATOR | back to summary |
|---|---|
| public static final String EOF_STATEMENT_SEPARATOR End of file (EOF) SQL statement separator: This value may be supplied as the | |
| FALLBACK_STATEMENT_SEPARATOR | back to summary |
|---|---|
| public static final String FALLBACK_STATEMENT_SEPARATOR Fallback statement separator within SQL scripts: Used if neither a custom separator nor the
| |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| ScriptUtils | back to summary |
|---|---|
| public ScriptUtils() | |
| appendSeparatorToScriptIfNecessary | back to summary |
|---|---|
| private static void appendSeparatorToScriptIfNecessary(StringBuilder scriptBuilder, String separator) | |
| containsStatementSeparator | back to summary |
|---|---|
| pack-priv static boolean containsStatementSeparator(EncodedResource resource, String script, String separator, String[] commentPrefixes, String blockCommentStartDelimiter, String blockCommentEndDelimiter) throws ScriptException Determine if the provided SQL script contains the specified statement separator. This method is intended to be used to find the string separating each SQL statement — for example, a ';' character. Any occurrence of the separator within the script will be ignored if it
is within a literal block of text enclosed in single quotes
(
| |
| executeSqlScript | back to summary |
|---|---|
| public static void executeSqlScript(Connection connection, Resource resource) throws ScriptException Execute the given SQL script using default settings for statement separators, comment delimiters, and exception handling flags. Statement separators and comments will be removed before executing individual statements within the supplied script. Warning this method does not release the
provided
| |
| executeSqlScript | back to summary |
|---|---|
| public static void executeSqlScript(Connection connection, EncodedResource resource) throws ScriptException Execute the given SQL script using default settings for statement separators, comment delimiters, and exception handling flags. Statement separators and comments will be removed before executing individual statements within the supplied script. Warning this method does not release the
provided
| |
| executeSqlScript | back to summary |
|---|---|
| public static void executeSqlScript(Connection connection, EncodedResource resource, boolean continueOnError, boolean ignoreFailedDrops, String commentPrefix, String separator, String blockCommentStartDelimiter, String blockCommentEndDelimiter) throws ScriptException Execute the given SQL script. Statement separators and comments will be removed before executing individual statements within the supplied script. Warning this method does not release the
provided
| |
| executeSqlScript | back to summary |
|---|---|
| public static void executeSqlScript(Connection connection, EncodedResource resource, boolean continueOnError, boolean ignoreFailedDrops, String[] commentPrefixes, String separator, String blockCommentStartDelimiter, String blockCommentEndDelimiter) throws ScriptException Execute the given SQL script. Statement separators and comments will be removed before executing individual statements within the supplied script. Warning this method does not release the
provided
| |
| readScript | back to summary |
|---|---|
| pack-priv static String readScript(EncodedResource resource, String separator, String[] commentPrefixes, String blockCommentEndDelimiter) throws IOException Read a script from the provided resource, using the supplied comment prefixes
and statement separator, and build a Lines beginning with one of the comment prefixes are excluded from the results; however, line comments anywhere else — for example, within a statement — will be included in the results.
| |
| readScript | back to summary |
|---|---|
| private static String readScript(LineNumberReader lineNumberReader, String[] commentPrefixes, String separator, String blockCommentEndDelimiter) throws IOException | |
| splitSqlScript | back to summary |
|---|---|
| pack-priv static void splitSqlScript(EncodedResource resource, String script, String separator, String[] commentPrefixes, String blockCommentStartDelimiter, String blockCommentEndDelimiter, List<String> statements) throws ScriptException Split an SQL script into separate statements delimited by the provided
separator string. Each individual statement will be added to the provided
Within the script, the provided
| |
| startsWithAny | back to summary |
|---|---|
| private static boolean startsWithAny(String script, String[] prefixes, int offset) | |