Class SQLDB
- java.lang.Object
-
- com.djrapitops.plan.storage.database.AbstractDatabase
-
- com.djrapitops.plan.storage.database.SQLDB
-
- All Implemented Interfaces:
Database
public abstract class SQLDB extends AbstractDatabase
Class containing main logic for different data related save and load functionality.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.djrapitops.plan.storage.database.Database
Database.State
-
-
Field Summary
Fields Modifier and Type Field Description protected PlanConfig
config
protected ErrorLogger
errorLogger
protected Locale
locale
protected net.playeranalytics.plugin.server.PluginLogger
logger
protected net.playeranalytics.plugin.scheduling.RunnableFactory
runnableFactory
-
Fields inherited from class com.djrapitops.plan.storage.database.AbstractDatabase
accessLock
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SQLDB(java.util.function.Supplier<java.util.UUID> serverUUIDSupplier, Locale locale, PlanConfig config, net.playeranalytics.plugin.scheduling.RunnableFactory runnableFactory, net.playeranalytics.plugin.server.PluginLogger logger, ErrorLogger errorLogger)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
equals(java.lang.Object o)
java.util.concurrent.Future<?>
executeTransaction(Transaction transaction)
Execute an SQL Transaction.abstract java.sql.Connection
getConnection()
net.playeranalytics.plugin.server.PluginLogger
getLogger()
net.playeranalytics.plugin.scheduling.RunnableFactory
getRunnableFactory()
java.util.function.Supplier<java.util.UUID>
getServerUUIDSupplier()
int
hashCode()
void
init()
Initializes the Database.<T> T
query(Query<T> query)
Execute an SQL Query statement to get a result.abstract void
returnToPool(java.sql.Connection connection)
void
setTransactionExecutorServiceProvider(java.util.function.Supplier<java.util.concurrent.ExecutorService> transactionExecutorServiceProvider)
abstract void
setupDataSource()
Set up the source for connections.-
Methods inherited from class com.djrapitops.plan.storage.database.AbstractDatabase
assumeNoMoreHeavyLoad, getHeavyLoadDelayMs, getState, increaseHeavyLoadDelay, isUnderHeavyLoad, setState
-
-
-
-
Field Detail
-
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 Detail
-
SQLDB
protected SQLDB(java.util.function.Supplier<java.util.UUID> 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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getServerUUIDSupplier
public java.util.function.Supplier<java.util.UUID> 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()
-
-