RunScript

Executes the contents of a SQL script file against a database. This tool is usually used to create a database from script. It can also be used to analyze performance problems by running the tool using Java profiler settings such as:
 java -Xrunhprof:cpu=samples ...


Methods
static ResultSet execute(Connection conn, Reader reader)
Executes the SQL commands in a script file against a database.
static void execute(String url, String user, String password, String fileName, String charsetName, boolean continueOnError)
Executes the SQL commands in a script file against a database.
static void main(String[] args)
The command line interface for this tool.
void run(String[] args)
void setCheckResults(boolean check)
If results of statements should be cross-checked with the expected output.
void setShowResults(boolean show)
If the statements as well as the results should be printed to the output.

static ResultSet execute(Connection conn, Reader reader) throws SQLException

Executes the SQL commands in a script file against a database.

Parameters:
conn - the connection to a database
reader - the reader
Returns:
the last result set

static void execute(String url, String user, String password, String fileName, String charsetName, boolean continueOnError) throws SQLException

Executes the SQL commands in a script file against a database.

Parameters:
url - the database URL
user - the user name
password - the password
fileName - the script file
charsetName - the character set name or null for UTF-8
continueOnError - if execution should be continued if an error occurs

static void main(String[] args) throws SQLException

The command line interface for this tool. The options must be split into strings like this: "-user", "sa",... Options are case sensitive. The following options are supported:
  • -help or -? (print the list of options)
  • -url jdbc:h2:... (database URL)
  • -user username
  • -password password
  • -script filename (default file name is backup.sql)
  • -driver driver (the JDBC driver class name; not required for most databases)
  • -quiet (do not print progress information)
  • -showResults (show the statements and the results of queries)
  • -checkResults (check if the query results match the expected results
  • -quiet (do not print progress information)
  • -options (to specify a list of options ;only for H2 and only when using the embedded mode)
To include local files when using remote databases, use the special syntax:
 @INCLUDE fileName
This syntax is only supported by this tool. Embedded RUNSCRIPT SQL statements will be executed by the database.

Parameters:
args - the command line arguments
Throws:
SQLException

void run(String[] args) throws SQLException


void setCheckResults(boolean check)

If results of statements should be cross-checked with the expected output. The expected result is the next line(s) of the script, commented.

Parameters:
check - true if yes

void setShowResults(boolean show)

If the statements as well as the results should be printed to the output.

Parameters:
show - true if yes