Class SqliteManager
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.SqliteManager
- All Implemented Interfaces:
DBManager,SyncDBManager,Copyable<DBManager>
-
Field Summary
Fields inherited from class io.github.mrtesz.teszcore.db.manager.sqlite.AbstractSqliteManager
dataSource, name, path, projectName, url -
Constructor Summary
ConstructorsConstructorDescriptionSqliteManager(@Nullable String path, @NotNull String name, @Nullable com.zaxxer.hikari.HikariDataSource dataSource, @Nullable String projectName) -
Method Summary
Modifier and TypeMethodDescriptionbooleancolumnExists(@NotNull String tableName, @NotNull String columnName) Show if a column exists in a tablecopy()Copy the executing classvoidcreateOrAlter(@NotNull DBTable dbTable) Create a database table using aDBTableobject, suitable for the DBManager (MariaDBManager:MariaDBTableSqliteManager:SqliteTable)intdeleteFrom(@NotNull String tableName, @Nullable String whereClause, @NotNull List<Object> whereParams) Delete entries with aListreplacing the question marks in thewhereClausee.g.:
deleteFrom("users", "userId = ?"intdeleteFrom(@NotNull String tableName, String whereClause) Delete entries e.g.:
deleteFrom("users", "userId = " + userId);intDrop a table from the database e.g.:
dropTable("current-weak-save");int[]executeBatchSql(@NotNull BatchSqlStatements sqlStatements, @NotNull String tableName) Executes multiple SQL statements with the same structure in batch mode for better performance
e.gint[]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 List<Object> sqlParams, @NotNull String tableName) intexecuteSql(@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");intexecuteSql(@NotNull String sql, @NotNull List<Object> sqlParams, @NotNull String tableName, @Nullable String type) Execute a SQL query with aListreplacing the question marks in thesql
e.g.:
executeSql("UPDATE users SET name = ?booleanindexExists(@NotNull String tableName, @NotNull String indexName) Show if an index exists in a tableintinsertIgnore(@NotNull String tableName, @NotNull Map<String, Object> values) intinsertInto(@NotNull String tableName, @NotNull Map<String, Object> values) intintMethods 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
-
Constructor Details
-
SqliteManager
-
-
Method Details
-
createOrAlter
Description copied from interface:SyncDBManagerCreate a database table using aDBTableobject, suitable for the DBManager (MariaDBManager:MariaDBTableSqliteManager:SqliteTable)- Specified by:
createOrAlterin interfaceSyncDBManager- Parameters:
dbTable- Table that is created or altered- Throws:
IllegalArgumentException- when thedbTableparam is not the suitable type for the DBManager
-
executeSql
public int executeSql(@NotNull @NotNull String sql, @NotNull @NotNull List<Object> sqlParams, @NotNull @NotNull String tableName, @Nullable @Nullable String type) Description copied from interface:SyncDBManagerExecute a SQL query with aListreplacing the question marks in thesql
e.g.:
executeSql("UPDATE users SET name = ? WHERE id = ?",List.of(username, userId), "users", "update username");- Specified by:
executeSqlin interfaceSyncDBManager- Parameters:
sql- Query that should be executedsqlParams- Values replacing the ?'s in thesqlquerytableName- Name of the table, querying totype- Type of execution- Returns:
- Return value of the
PreparedStatement.executeUpdate()
-
executeSql
public int executeSql(@NotNull @NotNull String sql, @NotNull @NotNull String tableName, @Nullable @Nullable String type) Description copied from interface:SyncDBManagerExecute a SQL query
e.g.:
executeSql("UPDATE users SET name = " + username + " WHERE id = " + userId, "users", "update username");- Specified by:
executeSqlin interfaceSyncDBManager- Parameters:
sql- Query that should be executedtableName- Name of the table, querying totype- Type of execution- Returns:
- Return value of
PreparedStatement.executeUpdate()
-
executeBatchSql
@Deprecated public int[] executeBatchSql(@NotNull @NotNull List<BatchSqlStatement> sqlStatements, @NotNull @NotNull String tableName) Deprecated.Description copied from interface:SyncDBManagerExecutes multiple SQL statements with the same structure in batch mode for better performance
e.g.:executeBatchSql(batchStatementList, "users", "batch update");- Specified by:
executeBatchSqlin interfaceSyncDBManager- Parameters:
sqlStatements- List of SQL statements with their parameterstableName- Name of the table, querying to- Returns:
- Return value of
Statement.executeBatch()
-
executeBatchSql
public int[] executeBatchSql(@NotNull @NotNull BatchSqlStatements sqlStatements, @NotNull @NotNull String tableName) Description copied from interface:SyncDBManagerExecutes multiple SQL statements with the same structure in batch mode for better performance
e.g.:executeBatchSql(batchStatementList, "users", "batch update");- Specified by:
executeBatchSqlin interfaceSyncDBManager- Parameters:
sqlStatements- List of SQL statements with their parameterstableName- Name of the table, querying to- Returns:
- Return value of
Statement.executeBatch()
-
executeSelect
public SelectionResults executeSelect(@NotNull @NotNull String sql, @NotNull @NotNull List<Object> sqlParams, @NotNull @NotNull String tableName) Description copied from interface:SyncDBManagerExecute 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 interfaceSyncDBManager- Parameters:
sql- Sql querysqlParams- Values replacing the ?'s in thesqlquerytableName- Name of the table, to select from- Returns:
SelectionResultsobject representing the result
-
executeSelect
public SelectionResults executeSelect(@NotNull @NotNull String sql, @NotNull @NotNull String tableName) Description copied from interface:SyncDBManagerExecute a selection query
e.g.
executeSelect("SELECT email, number FROM users WHERE username = Mr_Tesz", "users");- Specified by:
executeSelectin interfaceSyncDBManager- Parameters:
sql- Sql querytableName- Name of the table, to select from- Returns:
SelectionResultsobject representing the result
-
insertInto
public int insertInto(@NotNull @NotNull String tableName, @NotNull @NotNull Map<String, Object> values) Description copied from interface:SyncDBManagerInsert 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 interfaceSyncDBManager- Parameters:
tableName- Name of the table, inserting intovalues- Values to insert- Returns:
- Return value of
PreparedStatement.executeUpdate()
-
insertIgnore
public int insertIgnore(@NotNull @NotNull String tableName, @NotNull @NotNull Map<String, Object> values) Description copied from interface:SyncDBManagerInsert 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 interfaceSyncDBManager- Parameters:
tableName- Name of the table, inserting intovalues- Values to insert- Returns:
- Return value of
PreparedStatement.executeUpdate()
-
deleteFrom
public int deleteFrom(@NotNull @NotNull String tableName, @Nullable @Nullable String whereClause, @NotNull @NotNull List<Object> whereParams) Description copied from interface:SyncDBManagerDelete entries with aListreplacing the question marks in thewhereClausee.g.:
deleteFrom("users", "userId = ?",List.of(userId));- Specified by:
deleteFromin interfaceSyncDBManager- Parameters:
tableName- Name of the table, deleting fromwhereClause- Clause, narrowing the targeted columnswhereParams- Values replacing the ?'s in thewhereClause- Returns:
- Number of rows affected
-
deleteFrom
Description copied from interface:SyncDBManagerDelete entries e.g.:
deleteFrom("users", "userId = " + userId);- Specified by:
deleteFromin interfaceSyncDBManager- Parameters:
tableName- Table namewhereClause- WHERE clause- Returns:
- Number of rows affected
-
update
public int update(@NotNull @NotNull String tableName, @NotNull @NotNull Map<String, Object> values, @Nullable @Nullable String whereClause, @NotNull @NotNull List<Object> whereParams) Description copied from interface:SyncDBManagerUpdate 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 interfaceSyncDBManager- Parameters:
tableName- Name of the table, updatingvalues- Values to updatewhereClause- Clause, narrowing the targeted columnswhereParams- Values replacing the ?'s in thewhereClause- Returns:
- Number of rows affected
-
update
public int update(@NotNull @NotNull String tableName, @NotNull @NotNull Map<String, Object> values, @Nullable @Nullable String whereClause) Description copied from interface:SyncDBManagerUpdate a table
e.g.:
Map<String, Object>values = newHashMapinvalid input: '<'>();
values.put("name", username);
update("users", values, "id = " + userId);- Specified by:
updatein interfaceSyncDBManager- Parameters:
tableName- Name of the table, updatingvalues- Values to updatewhereClause- Clause, narrowing the targeted columns- Returns:
- Number of rows affected
-
dropTable
Description copied from interface:SyncDBManagerDrop a table from the database e.g.:
dropTable("current-weak-save");- Specified by:
dropTablein interfaceSyncDBManager- Parameters:
tableName- Name of the table to drop- Returns:
- Return value of
PreparedStatement.executeUpdate()
-
columnExists
public boolean columnExists(@NotNull @NotNull String tableName, @NotNull @NotNull String columnName) Description copied from interface:SyncDBManagerShow if a column exists in a table- Specified by:
columnExistsin interfaceSyncDBManager- Parameters:
tableName- Name of the table, checkingcolumnName- Name of the column to be checked- Returns:
- true if the column exists
-
indexExists
Description copied from interface:SyncDBManagerShow if an index exists in a table- Specified by:
indexExistsin interfaceSyncDBManager- Parameters:
tableName- Name of the table, checkingindexName- Name of the index to be checked- Returns:
- true if the index exists
-
copy
Description copied from interface:CopyableCopy the executing class
-