All Implemented Interfaces:
Database
Direct Known Subclasses:
MySQLDB, SQLiteDB

public abstract class SQLDB extends AbstractDatabase
Class containing main logic for different data related save and load functionality.
  • Field Details

    • locale

      protected final Locale locale
    • config

      protected final PlanConfig config
    • runnableFactory

      protected final net.playeranalytics.plugin.scheduling.RunnableFactory runnableFactory
    • logger

      protected final net.playeranalytics.plugin.server.PluginLogger logger
    • errorLogger

      protected final ErrorLogger errorLogger
  • Constructor Details

    • SQLDB

      protected SQLDB(Supplier<ServerUUID> serverUUIDSupplier, Locale locale, PlanConfig config, net.playeranalytics.plugin.scheduling.RunnableFactory runnableFactory, net.playeranalytics.plugin.server.PluginLogger logger, ErrorLogger errorLogger)
  • Method Details

    • init

      public void init()
      Description copied from interface: Database
      Initializes the Database.

      Queries can be performed after this request has completed all required transactions for the database operations.

    • setupDataSource

      public abstract void setupDataSource()
      Set up the source for connections.
      Throws:
      DBInitException - If the DataSource fails to be initialized.
    • close

      public void close()
    • getConnection

      public abstract Connection getConnection() throws SQLException
      Throws:
      SQLException
    • returnToPool

      public abstract void returnToPool(Connection connection)
    • query

      public <T> T query(Query<T> query)
      Description copied from interface: Database
      Execute an SQL Query statement to get a result.

      This method should only be called from an asynchronous thread.

      Type Parameters:
      T - Type of the object to be returned.
      Parameters:
      query - QueryStatement to execute.
      Returns:
      Result of the query.
    • executeTransaction

      public Future<?> executeTransaction(Transaction transaction)
      Description copied from interface: Database
      Execute an SQL Transaction.
      Parameters:
      transaction - Transaction to execute.
      Returns:
      Future that is finished when the transaction has been executed.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getServerUUIDSupplier

      public Supplier<ServerUUID> getServerUUIDSupplier()
    • setTransactionExecutorServiceProvider

      public void setTransactionExecutorServiceProvider(Supplier<ExecutorService> transactionExecutorServiceProvider)
    • getRunnableFactory

      public net.playeranalytics.plugin.scheduling.RunnableFactory getRunnableFactory()
    • getLogger

      public net.playeranalytics.plugin.server.PluginLogger getLogger()