Class SqlScriptParser


  • public class SqlScriptParser
    extends Object
    This class represents a splitter of SQL script into separate statements. It respects the notion of a string literal and comments, such that if a separator appears in a string literal or comment, it is treated as part of the string or comment instead of a separator.
    Author:
    Alexander Buloichik
    • Constructor Detail

      • SqlScriptParser

        public SqlScriptParser​(boolean usingBackslashAsEscapeCharForQuotation)
        Parameters:
        usingBackslashAsEscapeCharForQuotation - use backslash as escape char for quotation (\')
    • Method Detail

      • split

        public List<String> split​(String script)
        This method splits script into separate statements.
        Parameters:
        script - a string representing the SQL script to parse
        Returns:
        the list of statements
      • removeComments

        public String removeComments​(String script)
        This method removes comments from one statement.
        Parameters:
        script - a string representing the SQL script to parse
        Returns:
        script without comments