Class SourceDatabaseReader

java.lang.Object
com.enhancedechest.migration.SourceDatabaseReader
All Implemented Interfaces:
AutoCloseable

public final class SourceDatabaseReader extends Object implements AutoCloseable
Opens an EnhancedEchest database of any supported dialect read-only and reads its players and enderchests tables (under the active install's database.table-prefix) verbatim, for the /ee import DB→DB copy. Unlike the vault-plugin migrators this does no item decoding: rows are read column-for-column (including the raw container_data bytes) and handed straight to EnderChestStorage.importRows(java.util.List<com.enhancedechest.storage.EnderChestStorage.RawPlayerRow>, java.util.List<com.enhancedechest.storage.EnderChestStorage.RawChestRow>).

The schema is assumed to already be at the current version — the docs instruct the admin to load the source with this plugin version first. No SchemaMigrator is run here; a missing column surfaces as a SQLException, which the service turns into a "source schema outdated" message rather than silently importing partial data. The source's tables are assumed to use the same table-prefix as the active destination, since both are the same plugin's schema.

Not thread-safe; open, readAll() and close() on one thread (the shared DB executor). Uses the same shaded/relocated drivers as the storage layer, registered via Class.forName(java.lang.String) so DriverManager can find them under Paper's plugin classloader.

  • Method Details

    • backend

      public String backend()
      The source backend name (e.g. "SQLite", "MySQL"), for logging.
    • open

      public static SourceDatabaseReader open(SourceSpec spec, Path dataFolder, org.slf4j.Logger log, String tablePrefix) throws Exception
      Opens the source database described by spec, read-only.
      Parameters:
      dataFolder - plugin data folder, used to resolve a relative SQLite file path
      tablePrefix - the active install's database.table-prefix, assumed shared with the source
      Throws:
      IllegalStateException - if the SQLite source file does not exist
      IllegalArgumentException - if the source type is unsupported
      Exception - if the driver is missing or the connection fails
    • readAll

      public SourceDatabaseReader.Data readAll() throws Exception
      Reads both tables in two forward-only queries — no per-player N+1.
      Throws:
      Exception
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable