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

    Constructors
    Constructor and Description
    `Recover()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `org.h2.value.CompareMode` | `getCompareMode()` Return compare mode.
    `java.lang.String` | `getDatabasePath()` INTERNAL
    `org.h2.util.SmallLRUCache<java.lang.String,java.lang.String[]>` | `getLobFileListCache()` INTERNAL
    `org.h2.store.LobStorageInterface` | `getLobStorage()` INTERNAL
    `java.lang.Object` | `getLobSyncObject()` INTERNAL
    `int` | `getMaxLengthInplaceLob()` INTERNAL
    `org.h2.util.TempFileDeleter` | `getTempFileDeleter()` INTERNAL
    `static void` | `main(java.lang.String... args)` Options are case sensitive.
    `org.h2.store.FileStore` | `openFile(java.lang.String name, java.lang.String mode, boolean mustExist)` INTERNAL
    `static java.io.InputStream` | `readBlobMap(java.sql.Connection conn, long lobId, long precision)` INTERNAL
    `static java.io.Reader` | `readClobMap(java.sql.Connection conn, long lobId, long precision)` INTERNAL
    `int` | `readLob(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length)` 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

      `isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, 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
      [-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

      Encrypted databases need to be decrypted first.
      Parameters:
        `args` - the command line arguments
      Throws:
        `java.sql.SQLException` - on failure

    - #### 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 file format, or if there is a hardware problem.
      Specified by:
        `runTool` in class `org.h2.util.Tool`
      Parameters:
        `args` - the command line arguments
      Throws:
        `java.sql.SQLException` - on failure

    - #### readBlobMap

          public static java.io.InputStream readBlobMap(java.sql.Connection conn,
                                                        long lobId,
                                                        long precision)
                                                 throws java.sql.SQLException

      INTERNAL
      Parameters:
        `conn` - to use
        `lobId` - id of the LOB stream
        `precision` - not used
      Returns:
        InputStream to read LOB content from
      Throws:
        `java.sql.SQLException` - on failure

    - #### readClobMap

          public static java.io.Reader readClobMap(java.sql.Connection conn,
                                                   long lobId,
                                                   long precision)
                                            throws java.lang.Exception

      INTERNAL
      Parameters:
        `conn` - to use
        `lobId` - id of the LOB stream
        `precision` - not used
      Returns:
        Reader to read LOB content from
      Throws:
        `java.sql.SQLException` - on failure
        `java.lang.Exception`

    - #### 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` - on failure

    - #### getDatabasePath

          public java.lang.String getDatabasePath()

      INTERNAL
      Specified by:
        `getDatabasePath` in interface `org.h2.store.DataHandler`
      Returns:
        the database path

    - #### openFile

          public org.h2.store.FileStore openFile(java.lang.String name,
                                                 java.lang.String mode,
                                                 boolean mustExist)

      INTERNAL
      Specified by:
        `openFile` in interface `org.h2.store.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 `org.h2.store.DataHandler`

    - #### checkWritingAllowed

          public void checkWritingAllowed()

      INTERNAL
      Specified by:
        `checkWritingAllowed` in interface `org.h2.store.DataHandler`

    - #### getMaxLengthInplaceLob

          public int getMaxLengthInplaceLob()

      INTERNAL
      Specified by:
        `getMaxLengthInplaceLob` in interface `org.h2.store.DataHandler`
      Returns:
        the maximum size

    - #### getLobSyncObject

          public java.lang.Object getLobSyncObject()

      INTERNAL
      Specified by:
        `getLobSyncObject` in interface `org.h2.store.DataHandler`
      Returns:
        the synchronization object

    - #### getLobFileListCache

          public org.h2.util.SmallLRUCache<java.lang.String,java.lang.String[]> getLobFileListCache()

      INTERNAL
      Specified by:
        `getLobFileListCache` in interface `org.h2.store.DataHandler`
      Returns:
        the cache or null

    - #### getTempFileDeleter

          public org.h2.util.TempFileDeleter getTempFileDeleter()

      INTERNAL
      Specified by:
        `getTempFileDeleter` in interface `org.h2.store.DataHandler`
      Returns:
        the temp file deleter

    - #### getLobStorage

          public org.h2.store.LobStorageInterface getLobStorage()

      INTERNAL
      Specified by:
        `getLobStorage` in interface `org.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 interface `org.h2.store.DataHandler`
      Parameters:
        `lobId` - the lob id
        `hmac` - the message authentication code
        `offset` - the offset within the lob
        `buff` - the target buffer
        `off` - the offset within the target buffer
        `length` - 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 interface `org.h2.store.DataHandler`
      Returns:
        Compare mode.