Class JdbcSqlScriptUtils

java.lang.Object
org.apache.gravitino.utils.jdbc.JdbcSqlScriptUtils

public final class JdbcSqlScriptUtils extends Object
Utility methods for parsing and executing SQL scripts.
  • Method Details

    • splitStatements

      public static List<String> splitStatements(String sqlContent)
      Splits SQL script content into executable statements.

      Lines starting with -- are treated as comments and removed before splitting.

      Parameters:
      sqlContent - SQL script content
      Returns:
      executable SQL statements in order
    • executeSqlScript

      public static void executeSqlScript(Connection connection, String sqlContent) throws SQLException
      Executes all SQL statements parsed from the script content.
      Parameters:
      connection - JDBC connection used to execute statements
      sqlContent - SQL script content
      Throws:
      SQLException - if statement execution fails