java.lang.Object
net.foxgenesis.database.AbstractDatabase
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
WatameBotDatabase
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDatabase(String name, ResourceUtils.ModuleResource operationsFile, ResourceUtils.ModuleResource setupFile) -
Method Summary
Modifier and TypeMethodDescriptionfinal StringgetName()protected final Stringprotected final booleanhasStatementID(String id) booleanisReady()protected <U> UmapCallable(String id, AbstractDatabase.SQLFunction<CallableStatement, U> func, Consumer<Throwable> error) protected <U> UmapStatement(String id, AbstractDatabase.SQLFunction<PreparedStatement, U> func, Consumer<Throwable> error) protected abstract voidonReady()protected Connectionprotected voidprepareCallable(String id, AbstractDatabase.SQLConsumer<CallableStatement> func, Consumer<Throwable> error) protected <U> CompletableFuture<U>prepareCallableAsync(String id, Function<CallableStatement, U> func) protected voidprepareStatement(String id, AbstractDatabase.SQLConsumer<PreparedStatement> func, Consumer<Throwable> error) protected <U> CompletableFuture<U>prepareStatementAsync(String id, Function<PreparedStatement, U> func) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.AutoCloseable
close
-
Field Details
-
logger
@Nonnull protected final org.slf4j.Logger logger
-
-
Constructor Details
-
AbstractDatabase
public AbstractDatabase(@Nonnull String name, @Nonnull ResourceUtils.ModuleResource operationsFile, @Nonnull ResourceUtils.ModuleResource setupFile)
-
-
Method Details
-
onReady
protected abstract void onReady() -
openConnection
- Throws:
SQLException
-
prepareStatementAsync
protected <U> CompletableFuture<U> prepareStatementAsync(String id, Function<PreparedStatement, U> func) -
prepareCallableAsync
protected <U> CompletableFuture<U> prepareCallableAsync(String id, Function<CallableStatement, U> func) -
prepareStatement
protected void prepareStatement(String id, AbstractDatabase.SQLConsumer<PreparedStatement> func, Consumer<Throwable> error) -
prepareCallable
protected void prepareCallable(String id, AbstractDatabase.SQLConsumer<CallableStatement> func, Consumer<Throwable> error) -
mapStatement
protected <U> U mapStatement(String id, AbstractDatabase.SQLFunction<PreparedStatement, U> func, Consumer<Throwable> error) -
mapCallable
protected <U> U mapCallable(String id, AbstractDatabase.SQLFunction<CallableStatement, U> func, Consumer<Throwable> error) -
hasStatementID
-
getRawStatement
-
getName
-
isReady
public boolean isReady()
-