Class MySQLDialect
- java.lang.Object
-
- xyz.srnyx.annoyingapi.storage.dialects.Dialect
-
- xyz.srnyx.annoyingapi.storage.dialects.sql.SQLDialect
-
- xyz.srnyx.annoyingapi.storage.dialects.sql.MySQLDialect
-
public class MySQLDialect extends SQLDialect
SQL dialect for MySQL database
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class xyz.srnyx.annoyingapi.storage.dialects.Dialect
Dialect.MigrationData
-
-
Field Summary
-
Fields inherited from class xyz.srnyx.annoyingapi.storage.dialects.sql.SQLDialect
cache, connection
-
Fields inherited from class xyz.srnyx.annoyingapi.storage.dialects.Dialect
dataManager
-
-
Constructor Summary
Constructors Constructor Description MySQLDialect(@NotNull DataManager dataManager)Creates a new MySQL dialect
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable java.sql.PreparedStatementcreateKeyImpl(@NotNull java.lang.String table, @NotNull java.lang.String key)Create a key in the given table@NotNull java.sql.PreparedStatementcreateTableImpl(@NotNull java.lang.String table)Create a table in the databaseprotected @NotNull java.sql.PreparedStatementgetAllValuesFromDatabaseImpl(@NotNull java.lang.String table)Get all values from the database@NotNull java.util.Optional<java.lang.String>getFromDatabaseImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.lang.String column)Get a value from the database@NotNull java.sql.PreparedStatementgetTablesImpl()Get all tables from the databasebooleanremoveFromDatabaseImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.lang.String column)Remove a value from the database@Nullable FailedSetsetToDatabaseImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.lang.String column, @NotNull java.lang.String value)Set a value to the database@NotNull java.util.Set<FailedSet>setToDatabaseImpl(@NotNull java.lang.String table, @NotNull java.lang.String target, @NotNull java.util.concurrent.ConcurrentHashMap<java.lang.String,Value> data)Set multiple values to the database-
Methods inherited from class xyz.srnyx.annoyingapi.storage.dialects.sql.SQLDialect
createKey, createTable, createTablesKeys, getAllValuesFromDatabase, getFromCacheImpl, getMigrationDataFromDatabaseImpl, getTables, markRemovedInCacheImpl, saveCacheImpl, saveCacheImpl, setToCacheImpl, setValuesParameters
-
Methods inherited from class xyz.srnyx.annoyingapi.storage.dialects.Dialect
getFromCache, getFromDatabase, getMigrationDataFromDatabase, markRemovedInCache, removeValueFromDatabase, saveCache, saveCache, setToCache, setToDatabase, setToDatabase, setToDatabase
-
-
-
-
Constructor Detail
-
MySQLDialect
public MySQLDialect(@NotNull @NotNull DataManager dataManager) throws ConnectionExceptionCreates a new MySQL dialect- Parameters:
dataManager-Dialect.dataManager- Throws:
ConnectionException- if a database connection error occurs
-
-
Method Detail
-
getTablesImpl
@NotNull public @NotNull java.sql.PreparedStatement getTablesImpl() throws java.sql.SQLExceptionDescription copied from class:SQLDialectGet all tables from the database- Specified by:
getTablesImplin classSQLDialect- Returns:
- the
PreparedStatementwith the set parameters - Throws:
java.sql.SQLException- if a database error occurs
-
createTableImpl
@NotNull public @NotNull java.sql.PreparedStatement createTableImpl(@NotNull @NotNull java.lang.String table) throws java.sql.SQLExceptionDescription copied from class:SQLDialectCreate a table in the database- Specified by:
createTableImplin classSQLDialect- Parameters:
table- the table to create- Returns:
- the
PreparedStatementwith the set parameters - Throws:
java.sql.SQLException- if a database error occurs
-
createKeyImpl
@Nullable public @Nullable java.sql.PreparedStatement createKeyImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String key) throws java.sql.SQLExceptionDescription copied from class:SQLDialectCreate a key in the given table- Specified by:
createKeyImplin classSQLDialect- Parameters:
table- the table to create the key inkey- the key to create- Returns:
- the
PreparedStatementwith the set parameters - Throws:
java.sql.SQLException- if a database error occurs
-
getAllValuesFromDatabaseImpl
@NotNull protected @NotNull java.sql.PreparedStatement getAllValuesFromDatabaseImpl(@NotNull @NotNull java.lang.String table) throws java.sql.SQLExceptionDescription copied from class:SQLDialectGet all values from the database- Specified by:
getAllValuesFromDatabaseImplin classSQLDialect- Parameters:
table- the table to get the values from- Returns:
- the
PreparedStatementwith the set parameters - Throws:
java.sql.SQLException- if a database error occurs
-
getFromDatabaseImpl
@NotNull public @NotNull java.util.Optional<java.lang.String> getFromDatabaseImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String column)Description copied from class:DialectGet a value from the database- Specified by:
getFromDatabaseImplin classDialect- Parameters:
table- the table to get fromtarget- the target to get fromcolumn- the key to get- Returns:
- the value, empty if not found
-
setToDatabaseImpl
@Nullable public @Nullable FailedSet setToDatabaseImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String column, @NotNull @NotNull java.lang.String value)
Description copied from class:DialectSet a value to the database- Specified by:
setToDatabaseImplin classDialect- Parameters:
table- the table to set totarget- the target to set tocolumn- the key to setvalue- the value to set- Returns:
- the failed value information, null if successful
-
setToDatabaseImpl
@NotNull public @NotNull java.util.Set<FailedSet> setToDatabaseImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.util.concurrent.ConcurrentHashMap<java.lang.String,Value> data)
Description copied from class:DialectSet multiple values to the database- Specified by:
setToDatabaseImplin classDialect- Parameters:
table- the table to set totarget- the target to set todata- the data to set- Returns:
- set of failed values as
FailedSets
-
removeFromDatabaseImpl
public boolean removeFromDatabaseImpl(@NotNull @NotNull java.lang.String table, @NotNull @NotNull java.lang.String target, @NotNull @NotNull java.lang.String column)Description copied from class:DialectRemove a value from the database- Specified by:
removeFromDatabaseImplin classDialect- Parameters:
table- the table to remove fromtarget- the target to remove fromcolumn- the key to remove- Returns:
- true if the value was successfully removed, false otherwise
-
-