Package org.h2.tools
Class Recover
java.lang.Object
org.h2.util.Tool
org.h2.tools.Recover
- All Implemented Interfaces:
org.h2.store.DataHandler
public class Recover
extends org.h2.util.Tool
implements org.h2.store.DataHandler
Helps recovering a corrupted database.
-
Field Summary
Fields inherited from class org.h2.util.Tool
out
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
INTERNALvoid
INTERNALstatic void
Dumps the contents of a database to a SQL script file.org.h2.value.CompareMode
Return compare mode.INTERNALINTERNALorg.h2.store.LobStorageInterface
INTERNALINTERNALint
INTERNALorg.h2.util.TempFileDeleter
INTERNALstatic void
Options are case sensitive.org.h2.store.FileStore
INTERNALstatic InputStream
readBlobMap
(Connection conn, long lobId, long precision) INTERNALstatic Reader
readClobMap
(Connection conn, long lobId, long precision) INTERNALint
readLob
(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length) INTERNALvoid
Dumps the contents of a database file to a human readable text file.Methods inherited from class org.h2.util.Tool
getMainClassName, isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, throwUnsupportedOption
-
Constructor Details
-
Recover
public Recover()
-
-
Method Details
-
main
Options are case sensitive.Supported options [-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 [-transactionLog] Print the transaction log - Parameters:
args
- the command line arguments- Throws:
SQLException
- on failure
-
runTool
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 file format, or if there is a hardware problem.- Specified by:
runTool
in classorg.h2.util.Tool
- Parameters:
args
- the command line arguments- Throws:
SQLException
- on failure
-
readBlobMap
public static InputStream readBlobMap(Connection conn, long lobId, long precision) throws SQLException INTERNAL- Parameters:
conn
- to uselobId
- id of the LOB streamprecision
- not used- Returns:
- InputStream to read LOB content from
- Throws:
SQLException
- on failure
-
readClobMap
INTERNAL- Parameters:
conn
- to uselobId
- id of the LOB streamprecision
- not used- Returns:
- Reader to read LOB content from
- Throws:
SQLException
- on failureException
-
execute
Dumps the contents of a database to a SQL script file.- Parameters:
dir
- the directorydb
- the database name (null for all databases)- Throws:
SQLException
- on failure
-
getDatabasePath
INTERNAL- Specified by:
getDatabasePath
in interfaceorg.h2.store.DataHandler
- Returns:
- the database path
-
openFile
INTERNAL- Specified by:
openFile
in interfaceorg.h2.store.DataHandler
- Parameters:
name
- the file namemode
- the modemustExist
- whether the file must already exist- Returns:
- the file
-
checkPowerOff
public void checkPowerOff()INTERNAL- Specified by:
checkPowerOff
in interfaceorg.h2.store.DataHandler
-
checkWritingAllowed
public void checkWritingAllowed()INTERNAL- Specified by:
checkWritingAllowed
in interfaceorg.h2.store.DataHandler
-
getMaxLengthInplaceLob
public int getMaxLengthInplaceLob()INTERNAL- Specified by:
getMaxLengthInplaceLob
in interfaceorg.h2.store.DataHandler
- Returns:
- the maximum size
-
getLobSyncObject
INTERNAL- Specified by:
getLobSyncObject
in interfaceorg.h2.store.DataHandler
- Returns:
- the synchronization object
-
getLobFileListCache
INTERNAL- Specified by:
getLobFileListCache
in interfaceorg.h2.store.DataHandler
- Returns:
- the cache or null
-
getTempFileDeleter
public org.h2.util.TempFileDeleter getTempFileDeleter()INTERNAL- Specified by:
getTempFileDeleter
in interfaceorg.h2.store.DataHandler
- Returns:
- the temp file deleter
-
getLobStorage
public org.h2.store.LobStorageInterface getLobStorage()INTERNAL- Specified by:
getLobStorage
in interfaceorg.h2.store.DataHandler
- Returns:
- the lob storage mechanism
-
readLob
public int readLob(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length) INTERNAL- Specified by:
readLob
in interfaceorg.h2.store.DataHandler
- Parameters:
lobId
- the lob idhmac
- the message authentication codeoffset
- the offset within the lobbuff
- the target bufferoff
- the offset within the target bufferlength
- the number of bytes to read- Returns:
- the number of bytes read
-
getCompareMode
public org.h2.value.CompareMode getCompareMode()Description copied from interface:org.h2.store.DataHandler
Return compare mode.- Specified by:
getCompareMode
in interfaceorg.h2.store.DataHandler
- Returns:
- Compare mode.
-