Class ScriptCommand

java.lang.Object
org.seasar.doma.jdbc.command.ScriptCommand
All Implemented Interfaces:
Command<Void>

public class ScriptCommand extends Object implements Command<Void>
A command to execute SQL scripts.

This command reads and executes SQL statements from a script file.

  • Field Details

    • query

      protected final ScriptQuery query
      the query
    • savedScriptException

      protected ScriptException savedScriptException
      the saved script exception that occurred during execution
  • Constructor Details

    • ScriptCommand

      public ScriptCommand(ScriptQuery query)
      Creates a new instance.
      Parameters:
      query - the script query
      Throws:
      NullPointerException - if the query is null
  • Method Details

    • getQuery

      public ScriptQuery getQuery()
      Returns the query.
      Specified by:
      getQuery in interface Command<Void>
      Returns:
      the query
    • execute

      public Void execute()
      Executes the script.
      Specified by:
      execute in interface Command<Void>
      Returns:
      null
      Throws:
      ScriptException - if a script execution error occurs
    • log

      protected void log(ScriptCommand.ScriptSql sql)
      Logs the SQL statement.
      Parameters:
      sql - the SQL statement
    • setupOptions

      protected void setupOptions(Statement statement) throws SQLException
      Sets up options for the statement.
      Parameters:
      statement - the statement
      Throws:
      SQLException - if a database access error occurs
    • throwSavedScriptExceptionIfExists

      protected void throwSavedScriptExceptionIfExists()
      Throws the saved script exception if it exists.
      Throws:
      ScriptException - if a script execution error occurred