AsyncDBManager
| Type | 🟢 Interface |
| Package | io.github.mrtesz.teszcore.api.db.manager |
| GitHub | AsyncDBManager.java |
| Extends | DBManager |
Description
Parent interface of all async database managers
Methods
createOrAlter
CompletableFuture<Void> createOrAlter(@NotNull DBTable dbTable);
Create or alter a SQL table using a DBTable object
| Parameter | Type | Annotations | Description |
|---|---|---|---|
dbTable | <abbr title=io.github.mrtesz.teszcore.api.db.table.DBTable>DBTable</abbr> | @NotNull | Table that will be created or altered |
Returns: CompletableFuture<Void> — completes on finish or exceptionally on error
Throws: IllegalArgumentException when the provided DBTable is no suitable type for the executing AsyncDBManager
executeSql
CompletableFuture<Integer> executeSql(@NotNull String sql, @NotNull String tableName, @Nullable String type);
CompletableFuture<Integer> executeSql(@NotNull String sql, @NotNull String tableName, @NotNull List<Object> sqlParams, @Nullable String type);
Execute a SQL query
| Parameter | Type | Annotations | Description |
|---|---|---|---|
sql | String | @NotNull | Query that should be executed |
sqlParams | List<Object> | @NotNull | (optional) Values replacing the ?’s in the sql query with statement.setObject |
tableName | String | @NotNull | The name of the table the statement is executed in - for logging |
type | String | @Nullable | The type of execute e.g.: insert |
Returns: CompletableFuture<Integer> — completes with the number of affected rows or exceptionally on error
executeSelect
CompletableFuture<SelectionResults> executeSelect(@NotNull String sql, @NotNull List<Object> sqlParams, @NotNull String tableName);
CompletableFuture<SelectionResults> executeSelect(@NotNull String sql, @NotNull String tableName);
Execute a selection query
| Parameter | Type | Annotations | Description |
|---|---|---|---|
sql | String | @NotNull | The selection query to be executed |
sqlParams | List<Object> | @NotNull | (optional) Values replacing the ?’s in the sql query with statement.setObject |
tableName | String | @NotNull | The name of the table the statement is executed in - for logging |
Returns: CompletableFuture<SelectionResults> — completes with the query results represented as a <abbr title=io.github.mrtesz.teszcore.db.selection.SelectionResults>SelectionResults</abbr> Object or exceptionally on error
insertInto
CompletableFuture<Integer> insertInto(@NotNull String tableName, @NotNull Map<String, Object> values);
Insert into a table
| Parameter | Type | Annotations | Description |
|---|---|---|---|
tableName | String | @NotNull | The name of the table, inserting into |
values | Map<String, Object> | @NotNull | Values to insert |
Returns: CompletableFuture<Integer> — completes with the number of affected rows or exceptionally on error
insertIgnore
CompletableFuture<Integer> insertIgnore(@NotNull String tableName, @NotNull Map<String, Object> values);
Insert into a table, ignoring duplicate key violations or other constraint issues
| Parameter | Type | Annotations | Description |
|---|---|---|---|
tableName | String | @NotNull | The name of the table inserted to |
values | Map<String, Object> | @NotNull | Values to insert |
Returns: CompletableFuture<Integer> — completes with the number of affected rows or exceptionally on error
deleteFrom
CompletableFuture<Integer> deleteFrom(@NotNull String tableName, @Nullable String whereClause, @NotNull List<Object> whereParams);
CompletableFuture<Integer> deleteFrom(@NotNull String tableName, @Nullable String whereClause);
Delete values from a table
| Parameter | Type | Annotations | Description |
|---|---|---|---|
tableName | String | @NotNull | The name of the table inserted to |
whereClause | String | @Nullable | Clause, narrowing the targeted columns |
whereParams | List<Object> | @NotNull | (optional) Values replacing the ?’s in the whereClause |
Returns: CompletableFuture<Integer> — completes with the number of affected rows or exceptionally on error
update
CompletableFuture<Integer> update(@NotNull String tableName, @NotNull Map<String, Object> values, @Nullable String whereClause, @NotNull List<Object> whereParams);
CompletableFuture<Integer> update(@NotNull String tableName, @NotNull Map<String, Object> values, @Nullable String whereClause);
Update values of a table
| Parameter | Type | Annotations | Description |
|---|---|---|---|
tableName | String | @NotNull | The name of the table inserted to |
values | Map<String, Object | @NotNull | Values to update |
whereClause | String | @Nullable | Clause, narrowing the targeted columns |
whereParams | List<Object> | @NotNull | (optional) Values replacing the ?’s in the whereClause |
Returns: CompletableFuture<Integer> — completes with the number of affected rows or exceptionally on error
dropTable
CompletableFuture<Integer> dropTable(@NotNull String tableName);
Drop a table
| Parameter | Type | Annotations | Description |
|---|---|---|---|
tableName | String | @NotNull | Name of the table to drop |
Returns: CompletableFuture<Integer> — completes with the number of affected tables or exceptionally on error
columnExists
CompletableFuture<Boolean> columnExists(@NotNull String tableName, @NotNull String columnName);
Check if a column in a specific table exists
| Parameter | Type | Annotations | Description |
|---|---|---|---|
tableName | String | @NotNull | Name of the table to check |
columnName | String | @NotNull | Name of the column to be checked |
Returns: CompletableFuture<Boolean> — completes with true when the column exists, false when the column does not exist or exceptionally on error
indexExists
CompletableFuture<Boolean> indexExists(@NotNull String tableName, @NotNull String indexName);
Check if an index in a specific table exists
| Parameter | Type | Annotations | Description |
|---|---|---|---|
tableName | String | @NotNull | Name of the table to check |
indexName | String | @NotNull | Name of the index to be checked |
Returns: CompletableFuture<Boolean> — completes with true when the index exists, false when the index does not exist or exceptionally on error