Class SQLDB

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

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

      • locale

        protected final Locale locale
      • runnableFactory

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

        protected final net.playeranalytics.plugin.server.PluginLogger logger
    • Constructor Detail

      • SQLDB

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

      • 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 java.sql.Connection getConnection()
                                                   throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • returnToPool

        public abstract void returnToPool​(java.sql.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 java.util.concurrent.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​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.util.function.Supplier<ServerUUID> getServerUUIDSupplier()
      • setTransactionExecutorServiceProvider

        public void setTransactionExecutorServiceProvider​(java.util.function.Supplier<java.util.concurrent.ExecutorService> transactionExecutorServiceProvider)
      • getRunnableFactory

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

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