Package de.chojo.sqlutil.databases
Interface SqlType<T extends JdbcConfig<?>>
- Type Parameters:
T- type of the database defined by theSqlType
- All Known Implementing Classes:
DefaultType,MariaDb,MySql,Postgres,SqLite
public interface SqlType<T extends JdbcConfig<?>>
Defines a sql type and handles RDBMS specific actions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SqlType<MariaDbJdbc>The MariaDb type.The MySQL type.static final SqlType<PostgresJdbc>The PostgreSQL type.static final SqlType<SqLiteJdbc>The SqLite type. -
Method Summary
Modifier and TypeMethodDescriptiondefault 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.getName()Get a unique name to identify the database.getVersion(String table) Gets a query to read the version from the version tabledefault 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 StringReturns a query which returns a boolean indicating if a schema with this name exists.default String[]splitStatements(String queries) If the db does not allow to execute multiple queries this function should return every query in one string
-
Field Details
-
POSTGRES
The PostgreSQL type. -
MARIADB
The MariaDb type. -
SQLITE
The SqLite type. -
MYSQL
The MySQL type.
-
-
Method Details
-
createVersionTableQuery
Creates a query to create a version table on the database.The query needs to handle errors when the table exists.
- Parameters:
table- table name- Returns:
- query to create a version table
-
getVersion
Gets a query to read the version from the version table- Parameters:
table- table name- Returns:
- query to read the version table
-
getName
String getName()Get a unique name to identify the database.- Returns:
- database name
-
insertVersion
Creates a query to insert a version into the version table.Versions are always inserted and not updated.
- Parameters:
table- table name- Returns:
- query to insert the version.
-
deleteVersion
Creates a query to delete all entries from the version table.- Parameters:
table- table name- Returns:
- query to clear version table
-
schemaExists
Returns a query which returns a boolean indicating if a schema with this name exists.- Returns:
- query to check for schema
-
createSchema
Returns a query to create a schema with this name.- Parameters:
schema- schema- Returns:
- query to create schema
-
jdbcBuilder
T jdbcBuilder()Returns theJdbcConfigimplementation for this database- Returns:
- jdbc builder
-
splitStatements
If the db does not allow to execute multiple queries this function should return every query in one string- Parameters:
queries- queries- Returns:
- splitted queries if needed
-
cleanStatements
Function supposed to clean statements by removing empty statements- Parameters:
queries- queries- Returns:
- a new array
-
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
-