Class AsyncSqliteManager
java.lang.Object
io.github.mrtesz.teszcore.db.manager.AbstractDBManager
io.github.mrtesz.teszcore.db.manager.sqlite.AbstractSqliteManager
io.github.mrtesz.teszcore.db.manager.sqlite.AsyncSqliteManager
- All Implemented Interfaces:
AsyncDBManager,DBManager,Copyable<DBManager>
-
Field Summary
FieldsFields inherited from class io.github.mrtesz.teszcore.db.manager.sqlite.AbstractSqliteManager
dataSource, name, path, projectName, url -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAsyncSqliteManager(@Nullable String path, @NotNull String name, @Nullable com.zaxxer.hikari.HikariDataSource dataSource, @Nullable String projectName, int timeoutSeconds) -
Method Summary
Modifier and TypeMethodDescriptioncolumnExists(@NotNull String tableName, @NotNull String columnName) Show if a column exists in a tablecopy()Copy the executing classcreateOrAlter(@NotNull DBTable dbTable) Create a database table using aDBTableobject, suitable for the DBManager (AsyncMariaDBManager:MariaDBTableAsyncSqliteManager:SqliteTable)deleteFrom(@NotNull String tableName, @Nullable String whereClause) Delete entries
e.g.:
deleteFrom("users", "userId = " + userId);deleteFrom(@NotNull String tableName, @Nullable String whereClause, @NotNull List<Object> whereParams) Delete entries with aListreplacing the question marks in thewhereClause
e.g.:
deleteFrom("users", "userId = ?"Drop a table from the database
e.g.:
dropTable("current-weak-save");CompletableFuture<int[]> executeBatchSql(@NotNull BatchSqlStatements sqlStatements, @NotNull String tableName) Executes multiple SQL statements in batch mode for better performance
e.gCompletableFuture<int[]> executeBatchSql(@NotNull List<BatchSqlStatement> sqlStatements, @NotNull String tableName) Deprecated.executeSelect(@NotNull String sql, @NotNull String tableName) Execute a selection query
e.g.executeSelect(@NotNull String sql, @NotNull String tableName, @NotNull List<Object> sqlParams) executeSql(@NotNull String sql, @NotNull String tableName, @Nullable String type) Execute a SQL query
e.g.:
executeSql("UPDATE users SET name = " + username + " WHERE id = " + userId, "users", "update username");executeSql(@NotNull String sql, @NotNull String tableName, @Nullable String type, @NotNull List<Object> sqlParams) Execute a SQL query with aListreplacing the question marks in thesql
e.g.:
executeSql("UPDATE users SET name = ?indexExists(@NotNull String tableName, @NotNull String indexName) Show if an index exists in a tableinsertIgnore(@NotNull String tableName, @NotNull Map<String, Object> values) insertInto(@NotNull String tableName, @NotNull Map<String, Object> values) Methods inherited from class io.github.mrtesz.teszcore.db.manager.sqlite.AbstractSqliteManager
async, checkConnection, connect, createHikariConfig, disconnect, getConnection, syncMethods inherited from class io.github.mrtesz.teszcore.db.manager.AbstractDBManager
close, isClosedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.mrtesz.teszcore.api.db.manager.DBManager
async, async, buildSqlWithParams, checkConnection, close, connect, disconnect, getConnection, getName, isClosed, sync
-
Field Details
-
timeoutSeconds
protected final int timeoutSeconds
-
-
Constructor Details
-
AsyncSqliteManager
-
-
Method Details
-
createOrAlter
public CompletableFuture<Void> createOrAlter(@NotNull @NotNull DBTable dbTable) throws IllegalArgumentException Description copied from interface:AsyncDBManagerCreate a database table using aDBTableobject, suitable for the DBManager (AsyncMariaDBManager:MariaDBTableAsyncSqliteManager:SqliteTable)- Specified by:
createOrAlterin interfaceAsyncDBManager- Parameters:
dbTable- Table that is created or altered- Throws:
IllegalArgumentException- when thedbTableparam is not the suitable type for the DBManager
-
executeSql
public CompletableFuture<Integer> executeSql(@NotNull @NotNull String sql, @NotNull @NotNull String tableName, @Nullable @Nullable String type, @NotNull @NotNull List<Object> sqlParams) Description copied from interface:AsyncDBManagerExecute a SQL query with aListreplacing the question marks in thesql
e.g.:
executeSql("UPDATE users SET name = ? WHERE id = ?",syncList.of(username, userId), "users", "update username");- Specified by:
executeSqlin interfaceAsyncDBManager- Parameters:
sql- Query that should be executedtableName- Name of the table, querying totype- Type of the executionsqlParams- Values replacing the ?'s in thesqlquery- Returns:
- A
CompletableFuturesupplying the return value of thePreparedStatement.executeUpdate()
-
executeSql
public CompletableFuture<Integer> executeSql(@NotNull @NotNull String sql, @NotNull @NotNull String tableName, @Nullable @Nullable String type) Description copied from interface:AsyncDBManagerExecute a SQL query
e.g.:
executeSql("UPDATE users SET name = " + username + " WHERE id = " + userId, "users", "update username");- Specified by:
executeSqlin interfaceAsyncDBManager- Parameters:
sql- Query that should be executedtableName- Name of the table, querying totype- Type of the execution- Returns:
- A
CompletableFuturesupplying the return value of thePreparedStatement.executeUpdate()
-
executeBatchSql
@Deprecated public CompletableFuture<int[]> executeBatchSql(@NotNull @NotNull List<BatchSqlStatement> sqlStatements, @NotNull @NotNull String tableName) throws IllegalArgumentException Deprecated.Description copied from interface:AsyncDBManagerExecutes multiple SQL statements in batch mode for better performance
e.g.:executeBatchSql(batchStatementList, "users", "batch update");- Specified by:
executeBatchSqlin interfaceAsyncDBManager- Parameters:
sqlStatements- List of SQL statements with their parameterstableName- Name of the table, querying to- Returns:
- A
CompletableFuturesupplying the return value ofStatement.executeBatch() - Throws:
IllegalArgumentException- if the SQL statements are not the same structure
-
executeBatchSql
public CompletableFuture<int[]> executeBatchSql(@NotNull @NotNull BatchSqlStatements sqlStatements, @NotNull @NotNull String tableName) Description copied from interface:AsyncDBManagerExecutes multiple SQL statements in batch mode for better performance
e.g.:executeBatchSql(batchStatementList, "users", "batch update");- Specified by:
executeBatchSqlin interfaceAsyncDBManager- Parameters:
sqlStatements- List of SQL statements with their parameterstableName- Name of the table, querying to- Returns:
- A
CompletableFuturesupplying the return value ofStatement.executeBatch()
-
executeSelect
public CompletableFuture<SelectionResults> executeSelect(@NotNull @NotNull String sql, @NotNull @NotNull String tableName, @NotNull @NotNull List<Object> sqlParams) Description copied from interface:AsyncDBManagerExecute a selection query with aListreplacing the question marks in thesql
e.g.
executeSelect("SELECT email, number FROM users WHERE username = ?",List.of("Mr_Tesz"), "users");- Specified by:
executeSelectin interfaceAsyncDBManager- Parameters:
sql- Sql querytableName- Name of the table, to select fromsqlParams- Values replacing the ?'s in thesqlquery- Returns:
- A
CompletableFuturesupplying aSelectionResultsobject
-
executeSelect
public CompletableFuture<SelectionResults> executeSelect(@NotNull @NotNull String sql, @NotNull @NotNull String tableName) Description copied from interface:AsyncDBManagerExecute a selection query
e.g.
executeSelect("SELECT email, number FROM users WHERE username = Mr_Tesz", "users");- Specified by:
executeSelectin interfaceAsyncDBManager- Parameters:
sql- Sql querytableName- Name of the table, to select from- Returns:
- A
CompletableFuturesupplying aSelectionResultsobject
-
insertInto
public CompletableFuture<Integer> insertInto(@NotNull @NotNull String tableName, @NotNull @NotNull Map<String, Object> values) Description copied from interface:AsyncDBManagerInsert into a table
e.g.:
Map<String, Object>values = newHashMapinvalid input: '<'>();
values.put("id", userId);
values.put("name", username)
dbManager.insertInto("users", values);- Specified by:
insertIntoin interfaceAsyncDBManager- Parameters:
tableName- Name of the table, inserting intovalues- Values to insert- Returns:
- A
CompletableFuturesupplying the return value of thePreparedStatement.executeUpdate()
-
insertIgnore
public CompletableFuture<Integer> insertIgnore(@NotNull @NotNull String tableName, @NotNull @NotNull Map<String, Object> values) Description copied from interface:AsyncDBManagerInsert into a table ignoring when a unique is duplicated
e.g.:
Map<String, Object>values = newHashMapinvalid input: '<'>();
values.put("id", userId);
values.put("name", username);
dbManager.insertInto("users", values);- Specified by:
insertIgnorein interfaceAsyncDBManager- Parameters:
tableName- Name of the table, inserting intovalues- Values to insert- Returns:
- A
CompletableFuturesupplying the return value of thePreparedStatement.executeUpdate()
-
deleteFrom
public CompletableFuture<Integer> deleteFrom(@NotNull @NotNull String tableName, @Nullable @Nullable String whereClause, @NotNull @NotNull List<Object> whereParams) Description copied from interface:AsyncDBManagerDelete entries with aListreplacing the question marks in thewhereClause
e.g.:
deleteFrom("users", "userId = ?",List.of(userId));- Specified by:
deleteFromin interfaceAsyncDBManager- Parameters:
tableName- Name of the table, deleting fromwhereClause- Clause, narrowing the targeted columnswhereParams- Values replacing the ?'s in thewhereClause- Returns:
- A
CompletableFuturesupplying the rows affected
-
deleteFrom
public CompletableFuture<Integer> deleteFrom(@NotNull @NotNull String tableName, @Nullable @Nullable String whereClause) Description copied from interface:AsyncDBManagerDelete entries
e.g.:
deleteFrom("users", "userId = " + userId);- Specified by:
deleteFromin interfaceAsyncDBManager- Parameters:
tableName- Name of the table, deleting fromwhereClause- Clause, narrowing the targeted columns- Returns:
- A
CompletableFuturesupplying the rows affected
-
update
public CompletableFuture<Integer> update(@NotNull @NotNull String tableName, @NotNull @NotNull Map<String, Object> values, @Nullable @Nullable String whereClause, @NotNull @NotNull List<Object> whereParams) Description copied from interface:AsyncDBManagerUpdate a table with aListreplacing the question marks in thewhereClause
e.g.:
Map<String, Object>values = newHashMapinvalid input: '<'>();
values.put("name", username);
update("users", values, "id = ?",List.of(userId);- Specified by:
updatein interfaceAsyncDBManager- Parameters:
tableName- Name of the table, updatingvalues- Values to updatewhereClause- Clause, narrowing the targeted columnswhereParams- Values replacing the ?'s in thewhereClause- Returns:
- A
CompletableFuturesupplying the rows affected
-
update
public CompletableFuture<Integer> update(@NotNull @NotNull String tableName, @NotNull @NotNull Map<String, Object> values, @Nullable @Nullable String whereClause) Description copied from interface:AsyncDBManagerUpdate a table
e.g.:
Map<String, Object>values = newHashMapinvalid input: '<'>();
values.put("name", username);
update("users", values, "id = " + userId);- Specified by:
updatein interfaceAsyncDBManager- Parameters:
tableName- Name of the table, updatingvalues- Values to updatewhereClause- Clause, narrowing the targeted columns- Returns:
- A
CompletableFuturesupplying the rows affected
-
dropTable
Description copied from interface:AsyncDBManagerDrop a table from the database
e.g.:
dropTable("current-weak-save");- Specified by:
dropTablein interfaceAsyncDBManager- Parameters:
tableName- Name of the table to drop- Returns:
- A
CompletableFuturesupplying the return value of thePreparedStatement.executeUpdate()
-
columnExists
public CompletableFuture<Boolean> columnExists(@NotNull @NotNull String tableName, @NotNull @NotNull String columnName) Description copied from interface:AsyncDBManagerShow if a column exists in a table- Specified by:
columnExistsin interfaceAsyncDBManager- Parameters:
tableName- Name of the table, checkingcolumnName- Name of the column to be checked- Returns:
- A
CompletableFuturesupplying true if the column exists
-
indexExists
public CompletableFuture<Boolean> indexExists(@NotNull @NotNull String tableName, @NotNull @NotNull String indexName) Description copied from interface:AsyncDBManagerShow if an index exists in a table- Specified by:
indexExistsin interfaceAsyncDBManager- Parameters:
tableName- Name of the table, checkingindexName- Name of the index to be checked- Returns:
- A
CompletableFuturesupplying true if the index exists
-
copy
Description copied from interface:CopyableCopy the executing class
-