Package org.h2.tools
Class Restore
- java.lang.Object
-
- org.h2.util.Tool
-
- org.h2.tools.Restore
-
public class Restore extends Tool
Restores a H2 database by extracting the database files from a .zip file.
-
-
Constructor Summary
Constructors Constructor Description Restore()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidexecute(java.lang.String zipFileName, java.lang.String directory, java.lang.String db)Restores database files.private static java.lang.StringgetDatabaseNameFromFileName(java.lang.String fileName)Extract the name of the database from a given file name.private static java.lang.StringgetOriginalDbName(java.lang.String fileName, java.lang.String db)static voidmain(java.lang.String... args)Options are case sensitive.voidrunTool(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.SQLExceptionOptions are case sensitive. Supported optionsSupported options [-help] or [-?] Print the list of options [-file <filename>] The source file name (default: backup.zip) [-dir <dir>] The target directory (default: .) [-db <database>] The target database name (as stored if not set) [-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.SQLExceptionDescription copied from class:ToolRun the tool with the given output stream and arguments.
-
getOriginalDbName
private static java.lang.String getOriginalDbName(java.lang.String fileName, java.lang.String db) throws java.io.IOException- Throws:
java.io.IOException
-
getDatabaseNameFromFileName
private static java.lang.String getDatabaseNameFromFileName(java.lang.String fileName)
Extract the name of the database from a given file name. Only files ending with .h2.db are considered, all others return null.- Parameters:
fileName- the file name (without directory)- Returns:
- the database name or null
-
execute
public static void execute(java.lang.String zipFileName, java.lang.String directory, java.lang.String db)Restores database files.- Parameters:
zipFileName- the name of the backup filedirectory- the directory namedb- the database name (null for all databases)- Throws:
DbException- if there is an IOException
-
-