@Singleton public class QuerySvc extends java.lang.Object implements QueryService
QueryService.Holder, QueryService.ThrowingConsumer<T>, QueryService.ThrowingFunction<T,R>, QueryService.VoidFunction
Constructor and Description |
---|
QuerySvc(DBSystem dbSystem,
ServerInfo serverInfo,
com.djrapitops.plugin.logging.console.PluginLogger logger,
com.djrapitops.plugin.logging.error.ErrorHandler errorHandler) |
Modifier and Type | Method and Description |
---|---|
void |
dataCleared() |
java.util.concurrent.Future<?> |
execute(java.lang.String sql,
QueryService.ThrowingConsumer<java.sql.PreparedStatement> performStatement)
Execute SQL against Plan database.
|
CommonQueries |
getCommonQueries()
Perform some commonly wanted queries.
|
java.lang.String |
getDBType()
Get what kind of database is in use.
|
java.util.Optional<java.util.UUID> |
getServerUUID()
Get the UUID of this server.
|
void |
playerRemoved(java.util.UUID playerUUID) |
<T> T |
query(java.lang.String sql,
QueryService.ThrowingFunction<java.sql.PreparedStatement,T> performQuery)
Perform a query against Plan database.
|
void |
register() |
void |
subscribeDataClearEvent(QueryService.VoidFunction eventListener)
Used for getting notified about removal of ALL data.
|
void |
subscribeToPlayerRemoveEvent(java.util.function.Consumer<java.util.UUID> eventListener)
Used for getting notified about removal of player data.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInstance
@Inject public QuerySvc(DBSystem dbSystem, ServerInfo serverInfo, com.djrapitops.plugin.logging.console.PluginLogger logger, com.djrapitops.plugin.logging.error.ErrorHandler errorHandler)
public void register()
public java.lang.String getDBType()
QueryService
getDBType
in interface QueryService
public <T> T query(java.lang.String sql, QueryService.ThrowingFunction<java.sql.PreparedStatement,T> performQuery)
QueryService
Blocks thread until query is complete.
query
in interface QueryService
T
- Type of results.sql
- SQL String to execute, can contain parameterized queries (?
).performQuery
- set your parameters to the PreparedStatement and execute the query, return results.results
.public java.util.concurrent.Future<?> execute(java.lang.String sql, QueryService.ThrowingConsumer<java.sql.PreparedStatement> performStatement)
QueryService
Does not block thread, SQL is executed in a single transaction to the database.
Differs from QueryService.query(String, ThrowingFunction)
in that no results are returned.
execute
in interface QueryService
sql
- SQL String to execute, can contain parameterized queries (?
).performStatement
- set your parameters to the PreparedStatement and execute the statement.public void subscribeToPlayerRemoveEvent(java.util.function.Consumer<java.util.UUID> eventListener)
QueryService
SQL for removing this player's data should be executed when this occurs.
Example usage:
subscribeToPlayerRemoveEvent(playerUUID -> { do stuff })
subscribeToPlayerRemoveEvent
in interface QueryService
eventListener
- Functional interface that is called on the event.public void subscribeDataClearEvent(QueryService.VoidFunction eventListener)
QueryService
SQL for removing all extra tables (and data) should be performed
Example usage:
subscribeDataClearEvent(() -> { do stuff })
subscribeDataClearEvent
in interface QueryService
eventListener
- Functional interface that is called on the event.public void playerRemoved(java.util.UUID playerUUID)
public void dataCleared()
public java.util.Optional<java.util.UUID> getServerUUID()
QueryService
getServerUUID
in interface QueryService
public CommonQueries getCommonQueries()
QueryService
getCommonQueries
in interface QueryService
CommonQueries
implementation.