Interface SQLDatabaseType

All Known Implementing Classes:
DerbySQLDatabaseType, PostgreSQLDatabaseType, StaticSQLDatabaseType

public interface SQLDatabaseType
Interface for the SQL database types
  • Method Details

    • getId

      Get the id of the database type.
      Returns:
      the id. Can not be null.
    • getLabel

      Get the label of the database type.
      Returns:
      the label
    • getDriver

      Get the driver of the database type.
      Returns:
      the driver. Can not be null.
    • getValidationQuery

      Get the query to validate a connection
      Returns:
      A SQL query to ensure that a connection is still alive
    • getTemplate

      Get the url template to use for this database type
      Returns:
      the url template
    • getDriverNotFoundMessage

      Get the error message key when the specified driver was not found
      Returns:
      the error message
    • languageEscapeTableName

      Some db systems requires the table names to be escaped
      Parameters:
      tableNameToEscape - The non-null table name
      Returns:
      The escaped table name or at least the table name if no escape is required
    • languageLimitQuery

      String languageLimitQuery(String queryToLimit, String limit, String offset)
      Add a limit/offset element to the given query
      Parameters:
      queryToLimit - The sql query that will be amended
      limit - The max number of the results to return
      offset - The initial offset of the results to return
      Returns:
      The initial query amended to handle the limit and offset.
    • getBlob

      InputStream getBlob(ResultSet resultSet, String columnName) throws SQLException
      Get the InputStream to read a blob
      Parameters:
      resultSet - the result set containing the blob.
      columnName - column
      Returns:
      an InputStream to read the blob or null if the column is null
      Throws:
      SQLException - if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
    • getBlob

      InputStream getBlob(ResultSet resultSet, int pos) throws SQLException
      Get the InputStream to read a blob
      Parameters:
      resultSet - the result set containing the blob.
      pos - column position
      Returns:
      an InputStream to read the blob
      Throws:
      SQLException - if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
    • setBlob

      void setBlob(PreparedStatement statement, int pos, String blob) throws SQLException, UnsupportedEncodingException
      Set an String into a blob
      Parameters:
      statement - The satement where the blob will be set
      pos - position in the statement
      blob - String representing the blob. Can be null
      Throws:
      SQLException - if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
      UnsupportedEncodingException - if UTF-8 is not supported
    • setBlob

      void setBlob(PreparedStatement statement, int pos, byte[] bytes) throws SQLException
      Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can use setBlob(PreparedStatement, int, String)
      Parameters:
      statement - The satement where the blob will be set
      pos - position in the statement
      bytes - byte[] representing the blob, in UTF-8. Can be null
      Throws:
      SQLException - if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
    • setBlob

      void setBlob(PreparedStatement statement, int pos, InputStream is, long length) throws SQLException
      Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can use setBlob(PreparedStatement, int, String)
      Parameters:
      statement - The satement where the blob will be set
      pos - position in the statement
      is - inputStream to put in the blob. Can be null
      length - length of the stream
      Throws:
      SQLException - if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set