Interface Statement<R>

Type Parameters:
R - the result type returned by decodeResultSet(java.sql.ResultSet) or decodeAffectedRows(long)

public interface Statement<R>
Implemented by each query's parameter+result class. Provides a uniform way to prepare and execute statements against a JDBC Connection.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Bind to the prepared statement's parameter slots.
    decodeAffectedRows(long affectedRows)
    Decode an affected-row count into the statement's result type.
    Decode a result set into the statement's result type.
    default R
    Execute this statement using the provided JDBC connection.
    boolean
    Whether this statement returns rows (i.e. is a SELECT or contains a RETURNING clause).
    sql()
    The SQL text for this statement.
  • Method Details

    • sql

      String sql()
      The SQL text for this statement. Parameter placeholders use JDBC ? syntax; custom PostgreSQL types are cast explicitly, e.g. ?::album_format.
      Returns:
      the SQL text for this statement
    • bindParams

      void bindParams(PreparedStatement ps) throws SQLException
      Bind to the prepared statement's parameter slots.
      Parameters:
      ps - the prepared statement to bind parameters on
      Throws:
      SQLException - if a database access error occurs while binding
    • returnsRows

      boolean returnsRows()
      Whether this statement returns rows (i.e. is a SELECT or contains a RETURNING clause).
    • decodeResultSet

      R decodeResultSet(ResultSet rs) throws SQLException
      Decode a result set into the statement's result type.
      Parameters:
      rs - the result set positioned before the first row
      Returns:
      the decoded result of type R
      Throws:
      SQLException - if a database access error occurs while decoding
    • decodeAffectedRows

      R decodeAffectedRows(long affectedRows) throws SQLException
      Decode an affected-row count into the statement's result type.
      Parameters:
      affectedRows - the number of rows affected
      Returns:
      the decoded result of type R
      Throws:
      SQLException - if a database access error occurs while decoding
    • execute

      default R execute(Connection conn) throws SQLException
      Execute this statement using the provided JDBC connection.
      Parameters:
      conn - the JDBC connection to use
      Returns:
      the decoded statement result of type R
      Throws:
      SQLException - if a database access error occurs while executing the statement