Top Description Fields Constructors Methods
org.h2.tools

public Class Restore

extends Tool
Class Inheritance
Imports
java.io.File, .IOException, .InputStream, .OutputStream, java.sql.SQLException, java.util.zip.ZipEntry, .ZipInputStream, org.h2.engine.Constants, org.h2.message.DbException, org.h2.store.fs.FileUtils, org.h2.util.IOUtils, .Tool

Restores a H2 database by extracting the database files from a .zip file.

Field Summary

Inherited from org.h2.util.Tool:
out

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
execute(String
the name of the backup file
zipFileName
,
String
the directory name
directory
,
String
the database name (null for all databases)
db
)

Restores database files.

private static String

Returns:

the database name or null
getDatabaseNameFromFileName
(String
the file name (without directory)
fileName
)

Extract the name of the database from a given file name.

private static String
public static void
main(String...
the command line arguments
args
)

Options are case sensitive.

public void
runTool(String...
the argument list
args
)

Implements abstract org.h2.util.Tool.runTool.

Run the tool with the given output stream and arguments.

Inherited from org.h2.util.Tool:
getMainClassNameisOptionprintNoDatabaseFilesFoundsetOutshowUsageshowUsageAndThrowUnsupportedOptionthrowUnsupportedOption

Constructor Detail

Restoreback to summary
public Restore()

Method Detail

executeback to summary
public static void execute(String zipFileName, String directory, String db)

Restores database files.

Parameters
zipFileName:String

the name of the backup file

directory:String

the directory name

db:String

the database name (null for all databases)

Exceptions
DbException:
if there is an IOException
getDatabaseNameFromFileNameback to summary
private static String getDatabaseNameFromFileName(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:String

the file name (without directory)

Returns:String

the database name or null

getOriginalDbNameback to summary
private static String getOriginalDbName(String fileName, String db) throws IOException
mainback to summary
public static void main(String... args) throws SQLException

Options are case sensitive. Supported options

Supported 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:String[]

the command line arguments

Exceptions
SQLException:
on failure
runToolback to summary
public void runTool(String... args) throws SQLException

Implements abstract org.h2.util.Tool.runTool.

Doc from org.h2.util.Tool.runTool.

Run the tool with the given output stream and arguments.

Parameters
args:String[]

the argument list

Annotations
@Override
Exceptions
SQLException:
on failure