Interface Database<T extends JdbcConfig<?>, U extends UpdaterBuilder<T,?>>
- Type Parameters:
T- type of the database defined by theDatabaseU- type of the BaseSqlUpdater
- All Known Subinterfaces:
DefaultDatabase<T,U>
- All Known Implementing Classes:
MariaDb, MySql, PostgreSql, SqLite
public interface Database<T extends JdbcConfig<?>, U extends UpdaterBuilder<T,?>>
Defines a sql type and handles RDBMS specific actions.
Every type should implement two static methods, which provide the driver by name and one by get.
class MySqlType extends SqlType<MySqlTypeJdbc> {
private static final MySqlType type = MySqlType();
public static MySqlType mysqltype() {
return type;
}
public static MySqlType get() {
return type;
}
private MySqlType(){}
}
-
Method Summary
Modifier and TypeMethodDescriptiondefault String[]alias()Get the alias for the database name.default String[]cleanStatements(String[] queries) Function supposed to clean statements by removing empty statementsdefault StringcreateSchema(String schema) Returns a query to create a schema with this name.createVersionTableQuery(String table) Creates a query to create a version table on the database.deleteVersion(String table) Creates a query to delete all entries from the version table.default booleanIndicates if this type supports schemas.insertVersion(String table) Creates a query to insert a version into the version table.Returns theJdbcConfigimplementation for this databasedefault booleanname()Get a unique name to identify the database.Instantiates an implementation ofUpdaterBuilderdefault StringReturns a query which returns a boolean indicating if a schema with this name exists.default String[]splitStatements(String queries) The split queries, if the db does not allow to execute multiple queries this function should return every query in one string.versionQuery(String table) Gets a query to read the version from the version table
-
Method Details
-
createVersionTableQuery
-
versionQuery
-
name
-
alias
-
matches
-
insertVersion
-
deleteVersion
-
schemaExists
Returns a query which returns a boolean indicating if a schema with this name exists.- Returns:
- query to check for schema
-
createSchema
-
jdbcBuilder
-
splitStatements
-
cleanStatements
-
hasSchemas
default boolean hasSchemas()Indicates if this type supports schemas.When schemas are supported the methods
createSchema(String)andschemaExists()needs to be implemented.- Returns:
- true when schemas are supported
-
newSqlUpdaterBuilder
Instantiates an implementation ofUpdaterBuilder- Returns:
- the instance
-