Interface SqlType<T extends JdbcConfig<?>>

Type Parameters:
T - type of the database defined by the SqlType
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 Details

  • Method Details

    • createVersionTableQuery

      String createVersionTableQuery(String table)
      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

      String getVersion(String table)
      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

      String insertVersion(String table)
      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

      String deleteVersion(String table)
      Creates a query to delete all entries from the version table.
      Parameters:
      table - table name
      Returns:
      query to clear version table
    • schemaExists

      default String schemaExists()
      Returns a query which returns a boolean indicating if a schema with this name exists.
      Returns:
      query to check for schema
    • createSchema

      default String createSchema(String schema)
      Returns a query to create a schema with this name.
      Parameters:
      schema - schema
      Returns:
      query to create schema
    • jdbcBuilder

      T jdbcBuilder()
      Returns the JdbcConfig implementation for this database
      Returns:
      jdbc builder
    • splitStatements

      default String[] splitStatements(String queries)
      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

      default String[] cleanStatements(String[] queries)
      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) and schemaExists() needs to be implemented.

      Returns:
      true when schemas are supported