Package org.springframework.jdbc.core.simple

# Interface JdbcClient.StatementSpec

Enclosing interface:
  JdbcClient

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

## Method Summary

Modifier and Type
Method
Description
`JdbcClient.StatementSpec`
`param(int jdbcIndex, Object value)`
Bind a positional JDBC statement parameter for "?" placeholder resolution by explicit JDBC statement parameter index.
`JdbcClient.StatementSpec`
`param(int jdbcIndex, Object value, int sqlType)`
Bind a positional JDBC statement parameter for "?" placeholder resolution by explicit JDBC statement parameter index.
`JdbcClient.StatementSpec`
`param(Object value)`
Bind a positional JDBC statement parameter for "?" placeholder resolution by implicit order of parameter value registration.
`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.
`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.
`JdbcClient.StatementSpec`
`params(Object... values)`
Bind a var-args list of positional parameters for "?" placeholder resolution.
`JdbcClient.StatementSpec`
`params(List<?> values)`
Bind a list of positional parameters for "?" placeholder resolution.
`JdbcClient.StatementSpec`
`params(Map<String,?> paramMap)`
Bind named statement parameters for ":x" placeholder resolution.
`JdbcClient.StatementSpec`
`paramSource(Object namedParamObject)`
Bind named statement parameters for ":x" placeholder resolution.
`JdbcClient.StatementSpec`
`paramSource(SqlParameterSource namedParamSource)`
Bind named statement parameters for ":x" placeholder resolution.
`JdbcClient.ResultQuerySpec`
`query()`
Proceed towards execution of a query, with several result options available in the returned query specification.
`<T> JdbcClient.MappedQuerySpec<T>`
`query(Class<T> mappedClass)`
Proceed towards execution of a mapped query, with several options available in the returned query specification.
`<T> T`
`query(ResultSetExtractor<T> rse)`
Execute a query with the provided SQL statement, returning a result object for the entire ResultSet.
`void`
`query(RowCallbackHandler rch)`
Execute a query with the provided SQL statement, processing each row with the given callback.
`<T> JdbcClient.MappedQuerySpec<T>`
`query(RowMapper<T> rowMapper)`
Proceed towards execution of a mapped query, with several options available in the returned query specification.
`int`
`update()`
Execute the provided SQL statement as an update.
`int`
`update(KeyHolder generatedKeyHolder)`
Execute the provided SQL statement as an update.
`int`
`update(KeyHolder generatedKeyHolder, String... keyColumnNames)`
Execute the provided SQL statement as an update.

## Method Details

### param

JdbcClient.StatementSpec param(@Nullable Object value)
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 parameter 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:
  - `PreparedStatement.setObject(int, Object)`

### param

JdbcClient.StatementSpec param(int jdbcIndex, @Nullable 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:
  - `PreparedStatement.setObject(int, Object)`

### param

JdbcClient.StatementSpec param(int jdbcIndex, @Nullable 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:
  - `PreparedStatement.setObject(int, Object, int)`

### param

JdbcClient.StatementSpec param(String name, @Nullable 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:
  - `MapSqlParameterSource.addValue(String, Object)`

### param

JdbcClient.StatementSpec param(String name, @Nullable 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:
  - `MapSqlParameterSource.addValue(String, Object, int)`

### params

JdbcClient.StatementSpec params(Object... values)
Bind a var-args 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:
  - `param(Object)`
  - `params(List)`

### 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:
  - `param(Object)`

### 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:
  - `param(String, Object)`

### 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 (for example, a JavaBean, record class, or field holder) with named properties serving as statement parameters
Returns:
  this statement specification (for chaining)
See Also:
  - `paramSource(SqlParameterSource)`
  - `MapSqlParameterSource`
  - `SimplePropertySqlParameterSource`

### 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:
  - `AbstractSqlParameterSource.registerSqlType(java.lang.String, int)`

### query

JdbcClient.ResultQuerySpec query()
Proceed towards execution of a query, with several result options available in the returned query specification.

Returns:
  the result query specification
See Also:
  - `PreparedStatement.executeQuery()`

### 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(RowMapper)`
  - `SingleColumnRowMapper`
  - `SimplePropertyRowMapper`

### 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:
  - `PreparedStatement.executeQuery()`

### 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:
  - `PreparedStatement.executeQuery()`

### 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:
  - `PreparedStatement.executeQuery()`

### update

int update()
Execute the provided SQL statement as an update.

Returns:
  the number of rows affected
See Also:
  - `PreparedStatement.executeUpdate()`

### update

int update(KeyHolder generatedKeyHolder)
Execute the provided SQL statement as an update.

This method requires support for generated keys in the JDBC driver.

Parameters:
  `generatedKeyHolder` - a KeyHolder that will hold the generated keys (typically a `GeneratedKeyHolder`)
Returns:
  the number of rows affected
See Also:
  - `PreparedStatement.executeUpdate()`
  - `DatabaseMetaData.supportsGetGeneratedKeys()`

### update

int update(KeyHolder generatedKeyHolder, String... keyColumnNames)
Execute the provided SQL statement as an update.

This method requires support for generated keys in the JDBC driver.

Parameters:
  `generatedKeyHolder` - a KeyHolder that will hold the generated keys (typically a `GeneratedKeyHolder`)
  `keyColumnNames` - names of the columns that will have keys generated for them
Returns:
  the number of rows affected
See Also:
  - `PreparedStatement.executeUpdate()`
  - `DatabaseMetaData.supportsGetGeneratedKeys()`