Interface JdbcClient.StatementSpec

Enclosing interface:
JdbcClient

public static interface JdbcClient.StatementSpec
A statement specification for parameter bindings and query/update execution.
  • Method Details

    • param

      Bind a positional JDBC statement parameter for "?" placeholder resolution by implicit order of parameter value registration.

      This is primarily intended for statements with a single or very few parameters, registering each parameter value in the order of the parameter's occurrence in the SQL statement.

      Parameters:
      value - the parameter value to bind
      Returns:
      this statement specification (for chaining)
      See Also:
    • param

      JdbcClient.StatementSpec param(int jdbcIndex, Object value)
      Bind a positional JDBC statement parameter for "?" placeholder resolution by explicit JDBC statement parameter index.
      Parameters:
      jdbcIndex - the JDBC-style index (starting with 1)
      value - the parameter value to bind
      Returns:
      this statement specification (for chaining)
      See Also:
    • param

      JdbcClient.StatementSpec param(int jdbcIndex, Object value, int sqlType)
      Bind a positional JDBC statement parameter for "?" placeholder resolution by explicit JDBC statement parameter index.
      Parameters:
      jdbcIndex - the JDBC-style index (starting with 1)
      value - the parameter value to bind
      sqlType - the associated SQL type (see Types)
      Returns:
      this statement specification (for chaining)
      See Also:
    • param

      JdbcClient.StatementSpec param(String name, Object value)
      Bind a named statement parameter for ":x" placeholder resolution, with each "x" name matching a ":x" placeholder in the SQL statement.
      Parameters:
      name - the parameter name
      value - the parameter value to bind
      Returns:
      this statement specification (for chaining)
      See Also:
    • param

      JdbcClient.StatementSpec param(String name, Object value, int sqlType)
      Bind a named statement parameter for ":x" placeholder resolution, with each "x" name matching a ":x" placeholder in the SQL statement.
      Parameters:
      name - the parameter name
      value - the parameter value to bind
      sqlType - the associated SQL type (see Types)
      Returns:
      this statement specification (for chaining)
      See Also:
    • params

      JdbcClient.StatementSpec params(List<?> values)
      Bind a list of positional parameters for "?" placeholder resolution.

      The given list will be added to existing positional parameters, if any. Each element from the complete list will be bound as a JDBC positional parameter with a corresponding JDBC index (i.e. list index + 1).

      Parameters:
      values - the parameter values to bind
      Returns:
      this statement specification (for chaining)
      See Also:
    • params

      JdbcClient.StatementSpec params(Map<String,?> paramMap)
      Bind named statement parameters for ":x" placeholder resolution.

      The given map will be merged into existing named parameters, if any.

      Parameters:
      paramMap - a map of names and parameter values to bind
      Returns:
      this statement specification (for chaining)
      See Also:
    • paramSource

      JdbcClient.StatementSpec paramSource(Object namedParamObject)
      Bind named statement parameters for ":x" placeholder resolution.

      The given parameter object will define all named parameters based on its JavaBean properties, record components or raw fields. A Map instance can be provided as a complete parameter source as well.

      Parameters:
      namedParamObject - a custom parameter object (e.g. a JavaBean or record class or field holder) with named properties serving as statement parameters
      Returns:
      this statement specification (for chaining)
      See Also:
    • paramSource

      JdbcClient.StatementSpec paramSource(SqlParameterSource namedParamSource)
      Bind named statement parameters for ":x" placeholder resolution.

      The given parameter source will define all named parameters, possibly associating specific SQL types with each value.

      Parameters:
      namedParamSource - a custom SqlParameterSource instance
      Returns:
      this statement specification (for chaining)
      See Also:
    • query

      Proceed towards execution of a query, with several result options available in the returned query specification.
      Returns:
      the result query specification
      See Also:
    • query

      <T> JdbcClient.MappedQuerySpec<T> query(Class<T> mappedClass)
      Proceed towards execution of a mapped query, with several options available in the returned query specification.
      Parameters:
      mappedClass - the target class to apply a RowMapper for (either a simple value type for a single column mapping or a JavaBean / record class / field holder for a multi-column mapping)
      Returns:
      the mapped query specification
      See Also:
    • query

      <T> JdbcClient.MappedQuerySpec<T> query(RowMapper<T> rowMapper)
      Proceed towards execution of a mapped query, with several options available in the returned query specification.
      Parameters:
      rowMapper - the callback for mapping each row in the ResultSet
      Returns:
      the mapped query specification
      See Also:
    • query

      void query(RowCallbackHandler rch)
      Execute a query with the provided SQL statement, processing each row with the given callback.
      Parameters:
      rch - a callback for processing each row in the ResultSet
      See Also:
    • query

      <T> T query(ResultSetExtractor<T> rse)
      Execute a query with the provided SQL statement, returning a result object for the entire ResultSet.
      Parameters:
      rse - a callback for processing the entire ResultSet
      Returns:
      the value returned by the ResultSetExtractor
      See Also:
    • update

      int update()
      Execute the provided SQL statement as an update.
      Returns:
      the number of rows affected
      See Also:
    • update

      int update(KeyHolder generatedKeyHolder)
      Execute the provided SQL statement as an update.
      Parameters:
      generatedKeyHolder - a KeyHolder that will hold the generated keys (typically a GeneratedKeyHolder)
      Returns:
      the number of rows affected
      See Also: