This is an alternative to the classic
org. interface,
implemented by NamedParameterJdbcTemplate. This interface is not
often used directly, but provides a useful option to enhance testability,
as it can easily be mocked or stubbed.
NOTE: As of 6.1, there is a unified JDBC access facade available in
the form of org..
JdbcClient provides a fluent API style for common JDBC queries/updates
with flexible use of indexed or named parameters. It delegates to
JdbcOperations/NamedParameterJdbcOperations for actual execution.
NamedParameterJdbcTemplate, org.springframework.jdbc.core.JdbcOperations
| Modifier and Type | Method and Description |
|---|---|
| public int[] | Returns: an array containing the numbers of rows affected by each update in the batch (may also contain special JDBC-defined negative values for affected rows such asjava./java.)the SQL statement to execute sql, SqlParameterSource[] the array of batchArgs)SqlParameterSource containing the batch of
arguments for the queryExecute a batch using the supplied SQL statement with the batch of supplied arguments. |
| public int[] | Returns: an array containing the numbers of rows affected by each update in the batch (may also contain special JDBC-defined negative values for affected rows such asjava./java.)the SQL statement to execute sql, Map<String, ?>[] the array of Maps containing the batch of arguments for the query batchValues)Executes a batch using the supplied SQL statement with the batch of supplied arguments. |
| public int[] | Returns: an array containing the numbers of rows affected by each update in the batch (may also contain special JDBC-defined negative values for affected rows such asjava./java.)the SQL statement to execute sql, SqlParameterSource[] the array of batchArgs, KeyHolder SqlParameterSource containing the batch of
arguments for the querya generatedKeyHolder)KeyHolder that will hold the generated keysExecute a batch using the supplied SQL statement with the batch of supplied arguments, returning generated keys. |
| public int[] | Returns: an array containing the numbers of rows affected by each update in the batch (may also contain special JDBC-defined negative values for affected rows such asjava./java.)the SQL statement to execute sql, SqlParameterSource[] the array of batchArgs, KeyHolder SqlParameterSource containing the batch of
arguments for the querya generatedKeyHolder, String[] KeyHolder that will hold the generated keysnames of the columns that will have keys generated for them keyColumnNames)Execute a batch using the supplied SQL statement with the batch of supplied arguments, returning generated keys. |
| public <T> T | Returns: a result object returned by the action, ornullthe SQL to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, PreparedStatementCallback<T> callback object that specifies the action action)Execute a JDBC data access operation, implemented as callback action working on a JDBC PreparedStatement. |
| public <T> T | Returns: a result object returned by the action, ornullthe SQL to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, PreparedStatementCallback<T> callback object that specifies the action action)Execute a JDBC data access operation, implemented as callback action working on a JDBC PreparedStatement. |
| public <T> T | Returns: a result object returned by the action, ornullthe SQL to execute sql, PreparedStatementCallback<T> callback object that specifies the action action)Execute a JDBC data access operation, implemented as callback action working on a JDBC PreparedStatement. |
| public JdbcOperations | getJdbcOperations()
Expose the classic Spring JdbcTemplate to allow invocation of classic JDBC operations. |
| public <T> T | Returns: an arbitrary result object, as returned by the ResultSetExtractorthe SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, ResultSetExtractor<T> object that will extract results rse)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, reading the ResultSet with a ResultSetExtractor. |
| public <T> T | Returns: an arbitrary result object, as returned by the ResultSetExtractorthe SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, ResultSetExtractor<T> object that will extract results rse)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, reading the ResultSet with a ResultSetExtractor. |
| public <T> T | Returns: an arbitrary result object, as returned by the ResultSetExtractorthe SQL query to execute sql, ResultSetExtractor<T> object that will extract results rse)Query given SQL to create a prepared statement from SQL, reading the ResultSet with a ResultSetExtractor. |
| public void | query(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, RowCallbackHandler object that will extract results, one row at a time rch)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, reading the ResultSet on a per-row basis with a RowCallbackHandler. |
| public void | query(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, RowCallbackHandler object that will extract results, one row at a time rch)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, reading the ResultSet on a per-row basis with a RowCallbackHandler. |
| public void | query(String
the SQL query to execute sql, RowCallbackHandler object that will extract results, one row at a time rch)Query given SQL to create a prepared statement from SQL, reading the ResultSet on a per-row basis with a RowCallbackHandler. |
| public <T> List | Returns: the result List, containing mapped objectsthe SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, RowMapper<T> object that will map one object per row rowMapper)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper. |
| public <T> List | Returns: the result List, containing mapped objectsthe SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, RowMapper<T> object that will map one object per row rowMapper)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper. |
| public <T> List | |
| public <T> List | Returns: a List of objects that match the specified element typethe SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, Class<T> the required type of element in the result list
(for example, elementType)Integer.class)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list. |
| public <T> List | Returns: a List of objects that match the specified element typethe SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, Class<T> the required type of element in the result list
(for example, elementType)Integer.class)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list. |
| public List | Returns: a List that contains a Map per rowthe SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list. |
| public List | Returns: a List that contains a Map per rowthe SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list. |
| public Map | Returns: the result Map (one entry for each column, using the column name as the key)the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result Map. |
| public Map | Returns: the result Map (one entry for each column, using the column name as the key)the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result Map. |
| public <T> T | queryForObject(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, RowMapper<T> object that will map one object per row rowMapper)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping a single result row to a Java object via a RowMapper. |
| public <T> T | queryForObject(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, RowMapper<T> object that will map one object per row rowMapper)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping a single result row to a Java object via a RowMapper. |
| public <T> T | Returns: the result object of the required type, ornull in case of SQL NULLthe SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, Class<T> the type that the result object is expected to match requiredType)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result object. |
| public <T> T | Returns: the result object of the required type, ornull in case of SQL NULLthe SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, Class<T> the type that the result object is expected to match requiredType)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result object. |
| public SqlRowSet | Returns: an SqlRowSet representation (possibly a wrapper around ajavax.sql.rowset.CachedRowSet)the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting an SqlRowSet. |
| public SqlRowSet | Returns: an SqlRowSet representation (possibly a wrapper around ajavax.sql.rowset.CachedRowSet)the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting an SqlRowSet. |
| public <T> Stream | Returns: the result Stream, containing mapped objects, needing to be closed once fully processed (e.g. through a try-with-resources clause)the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, RowMapper<T> object that will map one object per row rowMapper)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper, and turning it into an iterable and closeable Stream. |
| public <T> Stream | Returns: the result Stream, containing mapped objects, needing to be closed once fully processed (e.g. through a try-with-resources clause)the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, RowMapper<T> object that will map one object per row rowMapper)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper, and turning it into an iterable and closeable Stream. |
| public int | Returns: the number of rows affectedthe SQL containing named parameters sql, SqlParameterSource container of arguments and SQL types to bind to the query paramSource)Issue an update via a prepared statement, binding the given arguments. |
| public int | |
| public int | Returns: the number of rows affectedthe SQL containing named parameters sql, SqlParameterSource container of arguments and SQL types to bind to the query paramSource, KeyHolder a generatedKeyHolder)KeyHolder that will hold the generated keysIssue an update via a prepared statement, binding the given arguments, returning generated keys. |
| public int | Returns: the number of rows affectedthe SQL containing named parameters sql, SqlParameterSource container of arguments and SQL types to bind to the query paramSource, KeyHolder a generatedKeyHolder, String[] KeyHolder that will hold the generated keysnames of the columns that will have keys generated for them keyColumnNames)Issue an update via a prepared statement, binding the given arguments, returning generated keys. |