Interface SQLDatabaseType

    • Method Detail

      • getId

        String getId()
        Get the id of the database type.
        Returns:
        the id. Can not be null.
      • getDriver

        String getDriver()
        Get the driver of the database type.
        Returns:
        the driver. Can not be null.
      • getValidationQuery

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

        String getTemplate()
        Get the url template to use for this database type
        Returns:
        the url template
      • languageEscapeTableName

        String languageEscapeTableName​(String tableNameToEscape)
        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,
                     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