org.h2.tools
Class Recover

java.lang.Object
  extended by org.h2.util.Tool
      extended by org.h2.tools.Recover
All Implemented Interfaces:
DataHandler

public class Recover
extends Tool
implements DataHandler

Helps recovering a corrupted database.

H2.resource:

Field Summary
 
Fields inherited from class org.h2.util.Tool
out
 
Constructor Summary
Recover()
           
 
Method Summary
 void checkPowerOff()
          INTERNAL
 void checkWritingAllowed()
          INTERNAL
static void execute(java.lang.String dir, java.lang.String db)
          Dumps the contents of a database to a SQL script file.
 void freeUpDiskSpace()
          INTERNAL
 java.lang.String getDatabasePath()
          INTERNAL
 java.lang.String getLobCompressionAlgorithm(int type)
          INTERNAL
 java.sql.Connection getLobConnection()
          INTERNAL
 SmallLRUCache<java.lang.String,java.lang.String[]> getLobFileListCache()
          INTERNAL
 LobStorage getLobStorage()
          INTERNAL
 java.lang.Object getLobSyncObject()
          INTERNAL
 int getMaxLengthInplaceLob()
          INTERNAL
 TempFileDeleter getTempFileDeleter()
          INTERNAL
static void main(java.lang.String... args)
          Options are case sensitive.
 FileStore openFile(java.lang.String name, java.lang.String mode, boolean mustExist)
          INTERNAL
static java.io.InputStream readBlob(java.lang.String fileName)
          INTERNAL
static Value.ValueBlob readBlobDb(java.sql.Connection conn, long lobId, long precision)
          INTERNAL
static java.io.Reader readClob(java.lang.String fileName)
          INTERNAL
static Value.ValueClob readClobDb(java.sql.Connection conn, long lobId, long precision)
          INTERNAL
 void runTool(java.lang.String... args)
          Dumps the contents of a database file to a human readable text file.
 
Methods inherited from class org.h2.util.Tool
printNoDatabaseFilesFound, setOut, showUsage, throwUnsupportedOption
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Recover

public Recover()
Method Detail

main

public static void main(java.lang.String... args)
                 throws java.sql.SQLException
Options are case sensitive. Supported options are:
[-help] or [-?] Print the list of options
[-dir <dir>] The directory (default: .)
[-db <database>] The database name (all databases if not set)
[-trace] Print additional trace information
Encrypted databases need to be decrypted first.

Parameters:
args - the command line arguments
Throws:
java.sql.SQLException
H2.resource:

runTool

public void runTool(java.lang.String... args)
             throws java.sql.SQLException
Dumps the contents of a database file to a human readable text file. This text file can be used to recover most of the data. This tool does not open the database and can be used even if the database files are corrupted. A database can get corrupted if there is a bug in the database engine or file system software, or if an application writes into the database file that doesn't understand the the file format, or if there is a hardware problem.

Specified by:
runTool in class Tool
Parameters:
args - the command line arguments
Throws:
java.sql.SQLException

readClob

public static java.io.Reader readClob(java.lang.String fileName)
                               throws java.io.IOException
INTERNAL

Throws:
java.io.IOException

readBlob

public static java.io.InputStream readBlob(java.lang.String fileName)
                                    throws java.io.IOException
INTERNAL

Throws:
java.io.IOException

readBlobDb

public static Value.ValueBlob readBlobDb(java.sql.Connection conn,
                                         long lobId,
                                         long precision)
INTERNAL


readClobDb

public static Value.ValueClob readClobDb(java.sql.Connection conn,
                                         long lobId,
                                         long precision)
INTERNAL


execute

public static void execute(java.lang.String dir,
                           java.lang.String db)
                    throws java.sql.SQLException
Dumps the contents of a database to a SQL script file.

Parameters:
dir - the directory
db - the database name (null for all databases)
Throws:
java.sql.SQLException

getDatabasePath

public java.lang.String getDatabasePath()
INTERNAL

Specified by:
getDatabasePath in interface DataHandler
Returns:
the database path

openFile

public FileStore openFile(java.lang.String name,
                          java.lang.String mode,
                          boolean mustExist)
INTERNAL

Specified by:
openFile in interface DataHandler
Parameters:
name - the file name
mode - the mode
mustExist - whether the file must already exist
Returns:
the file

checkPowerOff

public void checkPowerOff()
INTERNAL

Specified by:
checkPowerOff in interface DataHandler

checkWritingAllowed

public void checkWritingAllowed()
INTERNAL

Specified by:
checkWritingAllowed in interface DataHandler

freeUpDiskSpace

public void freeUpDiskSpace()
INTERNAL

Specified by:
freeUpDiskSpace in interface DataHandler

getMaxLengthInplaceLob

public int getMaxLengthInplaceLob()
INTERNAL

Specified by:
getMaxLengthInplaceLob in interface DataHandler
Returns:
the maximum size

getLobCompressionAlgorithm

public java.lang.String getLobCompressionAlgorithm(int type)
INTERNAL

Specified by:
getLobCompressionAlgorithm in interface DataHandler
Parameters:
type - the data type (CLOB or BLOB)
Returns:
the compression algorithm, or null

getLobSyncObject

public java.lang.Object getLobSyncObject()
INTERNAL

Specified by:
getLobSyncObject in interface DataHandler
Returns:
the synchronization object

getLobFileListCache

public SmallLRUCache<java.lang.String,java.lang.String[]> getLobFileListCache()
INTERNAL

Specified by:
getLobFileListCache in interface DataHandler
Returns:
the cache or null

getTempFileDeleter

public TempFileDeleter getTempFileDeleter()
INTERNAL

Specified by:
getTempFileDeleter in interface DataHandler
Returns:
the temp file deleter

getLobStorage

public LobStorage getLobStorage()
INTERNAL

Specified by:
getLobStorage in interface DataHandler
Returns:
the lob storage mechanism

getLobConnection

public java.sql.Connection getLobConnection()
INTERNAL

Specified by:
getLobConnection in interface DataHandler
Returns:
the connection or null