Interface JdbcClient.Statement

Enclosing interface:
JdbcClient

public static interface JdbcClient.Statement
Describes one prepared JDBC operation.

Bind positions use JDBC indexes, which start at one. The stage accepts exactly one terminal operation and is not safe for concurrent use.

  • Method Details

    • bind

      JdbcClient.Statement bind(int index, Object value)
      Binds a supported scalar value that is not null.
      Parameters:
      index - JDBC position, starting at one
      value - supported scalar value
      Returns:
      this statement
      Throws:
      NullPointerException - if the value is null
      IllegalArgumentException - if the position or value is invalid
      IllegalStateException - if a terminal operation has started
    • execute

      long execute()
      Executes an update and returns its update count as a long value.

      Helidon's JDBC provider uses the large update count when the driver supports it. Otherwise, the provider returns the legacy integer update count as a long value.

      A connection owned by the operation uses auto-commit. A failure reported after the update executes, including while processing the result or releasing JDBC resources, does not establish that the database made no changes. Applications must not retry the update automatically.

      Returns:
      update count
      Throws:
      DataException - if JDBC execution fails
      IllegalStateException - if a bind is missing or a terminal operation has started
    • map

      <T> JdbcClient.Rows<T> map(JdbcClient.RowMapper<T> mapper)
      Selects an explicit mapper for query rows.
      Type Parameters:
      T - mapped type
      Parameters:
      mapper - row mapper
      Returns:
      terminal stage for materialized rows
      Throws:
      NullPointerException - if the mapper is null
      IllegalStateException - if a terminal operation has started
    • map

      <T> JdbcClient.Rows<T> map(Class<T> scalarType)
      Selects mapping from the first column for a supported scalar type.

      JdbcClient.Rows.one() and JdbcClient.Rows.list() require a column value that is not null. JdbcClient.Rows.optional() returns Optional.empty() both when no row is returned and when exactly one row contains SQL NULL in column one. Applications that need to distinguish those states can use map(RowMapper) with a mapper that returns an Optional; the outer optional returned by JdbcClient.Rows.optional() then represents row presence.

      Type Parameters:
      T - mapped scalar type
      Parameters:
      scalarType - scalar type
      Returns:
      terminal stage for materialized rows
      Throws:
      NullPointerException - if the type is null
      IllegalArgumentException - if the scalar type is not supported
      IllegalStateException - if a terminal operation has started
    • generatedKeys

      JdbcClient.GeneratedKeys generatedKeys()
      Selects generated key execution.

      Adding no columns requests the driver's default generated keys. Configuration does not acquire JDBC resources.

      Returns:
      generated key configuration stage
      Throws:
      IllegalStateException - if a terminal operation has started