Class Recover
java.lang.Object
org.h2.util.Tool
org.h2.tools.Recover
- All Implemented Interfaces:
DataHandler
Helps recovering a corrupted database.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate booleanprivate intprivate ArrayList<MetaRecord> private intprivate Stringprivate booleanprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidINTERNALvoidINTERNALprivate voidcreateTemporaryTable(PrintWriter writer) private static voiddumpLayout(PrintWriter writer, MVStore mv) private voiddumpLobMaps(PrintWriter writer, MVStore mv) private static voiddumpMeta(PrintWriter writer, MVStore mv) private voiddumpMVStoreFile(PrintWriter writer, String fileName) private static voiddumpTypes(PrintWriter writer, MVStore mv) static voidDumps the contents of a database to a SQL script file.private static StringReturn compare mode.INTERNALINTERNALINTERNALINTERNALintINTERNALprivate voidgetSQL(StringBuilder builder, String column, Value v) INTERNALprivate PrintWriterprivate static booleanisLobTable(String name) private static booleanstatic voidOptions are case sensitive.INTERNALprivate voidstatic InputStreamreadBlobMap(Connection conn, long lobId, long precision) INTERNALstatic ReaderreadClobMap(Connection conn, long lobId, long precision) INTERNALintreadLob(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length) INTERNALprivate voidvoidDumps the contents of a database file to a human readable text file.private voidsetDatabaseName(String name) private StringsetStorage(int storageId) private voidprivate voidtraceError(String message, Throwable t) private voidwriteError(PrintWriter writer, Throwable e) private voidwriteMetaRow(Row r) private voidwriteSchema(PrintWriter writer) private voidwriteSchemaSET(PrintWriter writer) Methods inherited from class Tool
isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, throwUnsupportedOption
-
Field Details
-
databaseName
-
storageId
private int storageId -
storageName
-
recordLength
private int recordLength -
valueId
private int valueId -
trace
private boolean trace -
schema
-
objectIdSet
-
tableMap
-
columnTypeMap
-
lobMaps
private boolean lobMaps
-
-
Constructor Details
-
Recover
public Recover()
-
-
Method Details
-
main
Options are case sensitive.
Encrypted databases need to be decrypted first.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:
runToolin classTool- 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
-
trace
-
traceError
-
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
-
process
-
getWriter
-
getSQL
-
setDatabaseName
-
dumpMVStoreFile
-
dumpLayout
-
dumpMeta
-
dumpTypes
-
dumpLobMaps
-
setStorage
-
writeMetaRow
-
resetSchema
private void resetSchema() -
writeSchemaSET
-
writeSchema
-
isLobTable
-
isSchemaObjectTypeDelayed
-
createTemporaryTable
-
extractTableOrViewName
-
writeError
-
getDatabasePath
INTERNAL- Specified by:
getDatabasePathin interfaceDataHandler- Returns:
- the database path
-
openFile
INTERNAL- Specified by:
openFilein interfaceDataHandler- Parameters:
name- the file namemode- the modemustExist- whether the file must already exist- Returns:
- the file
-
checkPowerOff
-
checkWritingAllowed
public void checkWritingAllowed()INTERNAL- Specified by:
checkWritingAllowedin interfaceDataHandler
-
getMaxLengthInplaceLob
public int getMaxLengthInplaceLob()INTERNAL- Specified by:
getMaxLengthInplaceLobin interfaceDataHandler- Returns:
- the maximum size
-
getLobSyncObject
INTERNAL- Specified by:
getLobSyncObjectin interfaceDataHandler- Returns:
- the synchronization object
-
getLobFileListCache
INTERNAL- Specified by:
getLobFileListCachein interfaceDataHandler- Returns:
- the cache or null
-
getTempFileDeleter
INTERNAL- Specified by:
getTempFileDeleterin interfaceDataHandler- Returns:
- the temp file deleter
-
getLobStorage
INTERNAL- Specified by:
getLobStoragein interfaceDataHandler- Returns:
- the lob storage mechanism
-
readLob
public int readLob(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length) INTERNAL- Specified by:
readLobin interfaceDataHandler- 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
Description copied from interface:DataHandlerReturn compare mode.- Specified by:
getCompareModein interfaceDataHandler- Returns:
- Compare mode.
-