Package org.h2.tools
Class Script
- java.lang.Object
-
- org.h2.util.Tool
-
- org.h2.tools.Script
-
public class Script extends Tool
Creates a SQL script file by extracting the schema and data of a database.
-
-
Constructor Summary
Constructors Constructor Description Script()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String... args)
Options are case sensitive.static void
process(java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String fileName, java.lang.String options1, java.lang.String options2)
Backs up a database to a stream.static void
process(java.sql.Connection conn, java.lang.String fileName, java.lang.String options1, java.lang.String options2)
Backs up a database to a stream.void
runTool(java.lang.String... args)
Run the tool with the given output stream and arguments.-
Methods inherited from class org.h2.util.Tool
isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, throwUnsupportedOption
-
-
-
-
Method Detail
-
main
public static void main(java.lang.String... args) throws java.sql.SQLException
Options are case sensitive.Supported options [-help] or [-?] Print the list of options [-url "<url>"] The database URL (jdbc:...) [-user <user>] The user name (default: sa) [-password <pwd>] The password [-script <file>] The target script file name (default: backup.sql) [-options ...] A list of options (only for embedded H2, see SCRIPT) [-quiet] Do not print progress information - Parameters:
args
- the command line arguments- Throws:
java.sql.SQLException
- on failure
-
runTool
public void runTool(java.lang.String... args) throws java.sql.SQLException
Description copied from class:Tool
Run the tool with the given output stream and arguments.
-
process
public static void process(java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String fileName, java.lang.String options1, java.lang.String options2) throws java.sql.SQLException
Backs up a database to a stream.- Parameters:
url
- the database URLuser
- the user namepassword
- the passwordfileName
- the target file nameoptions1
- the options before the file name (may be an empty string)options2
- the options after the file name (may be an empty string)- Throws:
java.sql.SQLException
- on failure
-
process
public static void process(java.sql.Connection conn, java.lang.String fileName, java.lang.String options1, java.lang.String options2) throws java.sql.SQLException
Backs up a database to a stream. The stream is not closed. The connection is not closed.- Parameters:
conn
- the connectionfileName
- the target file nameoptions1
- the options before the file nameoptions2
- the options after the file name- Throws:
java.sql.SQLException
- on failure
-
-