SyncDBManager
| Type | 🟢 Interface |
| Package | io.github.mrtesz.teszcore.api.db.manager |
| GitHub | SyncDBManager.java |
| Extends | DBManager |
Description
Parent interface of all sync database managers
Methods
createOrAlter
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 |
Throws: IllegalArgumentException when the provided DBTable is no suitable type for the executing SyncDBManager
executeSql
int executeSql(@NotNull String sql, @NotNull String tableName, @Nullable String type);
int 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: int - the number of affected rows
executeSelect
SelectionResults executeSelect(@NotNull String sql, @NotNull List<Object> sqlParams, @NotNull String tableName);
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: SelectionResults — the query results represented as a <abbr title=io.github.mrtesz.teszcore.db.selection.SelectionResults>SelectionResults</abbr> Object
insertInto
int 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: int — the number of affected rows
insertIgnore
int 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: int — the number of affected rows
deleteFrom
int deleteFrom(@NotNull String tableName, @Nullable String whereClause, @NotNull List<Object> whereParams);
int 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: int — the number of affected rows
update
int update(@NotNull String tableName, @NotNull Map<String, Object> values, @Nullable String whereClause, @NotNull List<Object> whereParams);
int 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: int — the number of affected rows
dropTable
int dropTable(@NotNull String tableName);
Drop a table
| Parameter | Type | Annotations | Description |
|---|---|---|---|
tableName | String | @NotNull | Name of the table to drop |
Returns: int — the number of affected tables
columnExists
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: boolean — true when the column exists
indexExists
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: boolean — true when the index exists