Package co.aikar.idb
Interface Database
-
- All Known Implementing Classes:
BaseDatabase,HikariPooledDatabase
public interface Database
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclose()Called in onDisable, destroys the Data source and nulls out references.voidclose(long timeout, java.util.concurrent.TimeUnit unit)Called in onDisable, destroys the Data source and nulls out references.default voidcloseConnection(java.sql.Connection conn)default DbStatementcreateStatement()Initiates a new DbStatementdefault booleancreateTransaction(TransactionCallback run)default voidcreateTransactionAsync(TransactionCallback run)default voidcreateTransactionAsync(TransactionCallback run, java.lang.Runnable onSuccess, java.lang.Runnable onFail)<T> java.util.concurrent.CompletableFuture<T>dispatchAsync(java.util.concurrent.Callable<T> task)default java.lang.LongexecuteInsert(java.lang.String query, java.lang.Object... params)Utility method for executing an update synchronously that does an insert, closes the statement, and returns the last insert ID.default intexecuteUpdate(java.lang.String query, java.lang.Object... params)Utility method for executing an update synchronously, and then close the statement.default java.util.concurrent.CompletableFuture<java.lang.Integer>executeUpdateAsync(java.lang.String query, java.lang.Object... params)Utility method to execute an update statement asynchronously and close the connection.default voidfatalError(java.lang.Exception e)java.sql.ConnectiongetConnection()Get a JDBC Connectiondefault <T> TgetFirstColumn(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve the first column of the first row, then close statement.default <T> java.util.concurrent.CompletableFuture<T>getFirstColumnAsync(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve the first column of the first row, then close statement.default <T> java.util.List<T>getFirstColumnResults(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve first column of all results, then close statement.default <T> java.util.concurrent.CompletableFuture<java.util.List<T>>getFirstColumnResultsAsync(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve first column of all results, then close statement.default DbRowgetFirstRow(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve the first row, then close statement.default java.util.concurrent.CompletableFuture<DbRow>getFirstRowAsync(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve the first row, then close statement.java.util.logging.LoggergetLogger()Get the LoggerDatabaseOptionsgetOptions()Get the options objectdefault java.util.List<DbRow>getResults(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve all results, then close statement.default java.util.concurrent.CompletableFuture<java.util.List<DbRow>>getResultsAsync(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve all results, then close statement.default voidlogException(java.lang.Exception e)default voidlogException(java.lang.String message, java.lang.Exception e)default DbStatementquery(java.lang.String query)Initiates a new DbStatement and prepares the first query.default java.util.concurrent.CompletableFuture<DbStatement>queryAsync(java.lang.String query)Initiates a new DbStatement and prepares the first query.DatabaseTimingtimings(java.lang.String name)Create a Timings object
-
-
-
Method Detail
-
close
default void close()
Called in onDisable, destroys the Data source and nulls out references.
-
close
void close(long timeout, java.util.concurrent.TimeUnit unit)Called in onDisable, destroys the Data source and nulls out references.
-
dispatchAsync
<T> java.util.concurrent.CompletableFuture<T> dispatchAsync(java.util.concurrent.Callable<T> task)
-
getConnection
java.sql.Connection getConnection() throws java.sql.SQLExceptionGet a JDBC Connection- Throws:
java.sql.SQLException
-
timings
DatabaseTiming timings(java.lang.String name)
Create a Timings object
-
getLogger
java.util.logging.Logger getLogger()
Get the Logger
-
getOptions
DatabaseOptions getOptions()
Get the options object
-
fatalError
default void fatalError(java.lang.Exception e)
-
closeConnection
default void closeConnection(java.sql.Connection conn) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
createStatement
default DbStatement createStatement() throws java.sql.SQLException
Initiates a new DbStatement YOU MUST MANUALLY CLOSE THIS STATEMENT IN A finally {} BLOCK!- Throws:
java.sql.SQLException
-
query
default DbStatement query(java.lang.String query) throws java.sql.SQLException
Initiates a new DbStatement and prepares the first query. YOU MUST MANUALLY CLOSE THIS STATEMENT IN A finally {} BLOCK!- Throws:
java.sql.SQLException
-
queryAsync
default java.util.concurrent.CompletableFuture<DbStatement> queryAsync(java.lang.String query)
Initiates a new DbStatement and prepares the first query. YOU MUST MANUALLY CLOSE THIS STATEMENT IN A finally {} BLOCK!
-
getFirstRow
default DbRow getFirstRow(java.lang.String query, java.lang.Object... params) throws java.sql.SQLException
Utility method to execute a query and retrieve the first row, then close statement. You should ensure result will only return 1 row for maximum performance.- Parameters:
query- The query to runparams- The parameters to execute the statement with- Returns:
- DbRow of your results (HashMap with template return type)
- Throws:
java.sql.SQLException
-
getFirstRowAsync
default java.util.concurrent.CompletableFuture<DbRow> getFirstRowAsync(java.lang.String query, java.lang.Object... params)
Utility method to execute a query and retrieve the first row, then close statement. You should ensure result will only return 1 row for maximum performance.- Parameters:
query- The query to runparams- The parameters to execute the statement with- Returns:
- DbRow of your results (HashMap with template return type)
-
getFirstColumn
default <T> T getFirstColumn(java.lang.String query, java.lang.Object... params) throws java.sql.SQLExceptionUtility method to execute a query and retrieve the first column of the first row, then close statement. You should ensure result will only return 1 row for maximum performance.- Parameters:
query- The query to runparams- The parameters to execute the statement with- Returns:
- DbRow of your results (HashMap with template return type)
- Throws:
java.sql.SQLException
-
getFirstColumnAsync
default <T> java.util.concurrent.CompletableFuture<T> getFirstColumnAsync(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve the first column of the first row, then close statement. You should ensure result will only return 1 row for maximum performance.- Parameters:
query- The query to runparams- The parameters to execute the statement with- Returns:
- DbRow of your results (HashMap with template return type)
-
getFirstColumnResults
default <T> java.util.List<T> getFirstColumnResults(java.lang.String query, java.lang.Object... params) throws java.sql.SQLExceptionUtility method to execute a query and retrieve first column of all results, then close statement.Meant for single queries that will not use the statement multiple times.
- Throws:
java.sql.SQLException
-
getFirstColumnResultsAsync
default <T> java.util.concurrent.CompletableFuture<java.util.List<T>> getFirstColumnResultsAsync(java.lang.String query, java.lang.Object... params)Utility method to execute a query and retrieve first column of all results, then close statement.Meant for single queries that will not use the statement multiple times.
-
getResults
default java.util.List<DbRow> getResults(java.lang.String query, java.lang.Object... params) throws java.sql.SQLException
Utility method to execute a query and retrieve all results, then close statement.Meant for single queries that will not use the statement multiple times.
- Parameters:
query- The query to runparams- The parameters to execute the statement with- Returns:
- List of DbRow of your results (HashMap with template return type)
- Throws:
java.sql.SQLException
-
getResultsAsync
default java.util.concurrent.CompletableFuture<java.util.List<DbRow>> getResultsAsync(java.lang.String query, java.lang.Object... params)
Utility method to execute a query and retrieve all results, then close statement.Meant for single queries that will not use the statement multiple times.
- Parameters:
query- The query to runparams- The parameters to execute the statement with- Returns:
- List of DbRow of your results (HashMap with template return type)
-
executeInsert
default java.lang.Long executeInsert(java.lang.String query, java.lang.Object... params) throws java.sql.SQLExceptionUtility method for executing an update synchronously that does an insert, closes the statement, and returns the last insert ID.- Parameters:
query- Query to runparams- Params to execute the statement with.- Returns:
- Inserted Row Id.
- Throws:
java.sql.SQLException
-
executeUpdate
default int executeUpdate(java.lang.String query, java.lang.Object... params) throws java.sql.SQLExceptionUtility method for executing an update synchronously, and then close the statement.- Parameters:
query- Query to runparams- Params to execute the statement with.- Returns:
- Number of rows modified.
- Throws:
java.sql.SQLException
-
executeUpdateAsync
default java.util.concurrent.CompletableFuture<java.lang.Integer> executeUpdateAsync(java.lang.String query, java.lang.Object... params)Utility method to execute an update statement asynchronously and close the connection.- Parameters:
query- Query to runparams- Params to execute the update with
-
createTransactionAsync
default void createTransactionAsync(TransactionCallback run)
-
createTransactionAsync
default void createTransactionAsync(TransactionCallback run, java.lang.Runnable onSuccess, java.lang.Runnable onFail)
-
createTransaction
default boolean createTransaction(TransactionCallback run)
-
logException
default void logException(java.lang.String message, java.lang.Exception e)
-
logException
default void logException(java.lang.Exception e)
-
-