|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.jdbc.core.simple.SimpleJdbcTemplate
public class SimpleJdbcTemplate
Java-5-based convenience wrapper for the classic Spring
JdbcTemplate,
taking advantage of varargs and autoboxing, and exposing only the most
commonly required operations in order to simplify JdbcTemplate usage.
Use the getJdbcOperations() method (or a straight JdbcTemplate)
if you need to invoke less commonly used template methods. This includes
any methods specifying SQL types, methods using less commonly used callbacks
such as RowCallbackHandler, updates with PreparedStatementSetters rather than
argument arrays, and stored procedures as well as batch operations.
ParameterizedRowMapper,
SimpleJdbcDaoSupport,
JdbcTemplate| Constructor Summary | |
|---|---|
SimpleJdbcTemplate(DataSource dataSource)
Create a new SimpleJdbcTemplate for the given DataSource. |
|
SimpleJdbcTemplate(JdbcOperations classicJdbcTemplate)
Create a new SimpleJdbcTemplate for the given classic Spring JdbcTemplate. |
|
SimpleJdbcTemplate(NamedParameterJdbcOperations namedParameterJdbcTemplate)
Create a new SimpleJdbcTemplate for the given Spring NamedParameterJdbcTemplate. |
|
| Method Summary | ||
|---|---|---|
int[] |
batchUpdate(String sql,
List<Object[]> batchArgs)
Execute a batch using the supplied SQL statement with the batch of supplied arguments. |
|
int[] |
batchUpdate(String sql,
List<Object[]> batchArgs,
int[] argTypes)
Execute a batch using the supplied SQL statement with the batch of supplied arguments. |
|
int[] |
batchUpdate(String sql,
Map[] batchValues)
Executes a batch using the supplied SQL statement with the batch of supplied arguments. |
|
int[] |
batchUpdate(String sql,
SqlParameterSource[] batchArgs)
Execute a batch using the supplied SQL statement with the batch of supplied arguments. |
|
JdbcOperations |
getJdbcOperations()
Expose the classic Spring JdbcTemplate to allow invocation of less commonly used methods. |
|
NamedParameterJdbcOperations |
getNamedParameterJdbcOperations()
Expose the Spring NamedParameterJdbcTemplate to allow invocation of less commonly used methods. |
|
|
query(String sql,
ParameterizedRowMapper<T> rm,
Map args)
Query for a List of Objects of type T using
the supplied ParameterizedRowMapper to the query results to the object. |
|
|
query(String sql,
ParameterizedRowMapper<T> rm,
Object... args)
Query for a List of Objects of type T using
the supplied ParameterizedRowMapper to the query results to the object. |
|
|
query(String sql,
ParameterizedRowMapper<T> rm,
SqlParameterSource args)
Query for a List of Objects of type T using
the supplied ParameterizedRowMapper to the query results to the object. |
|
int |
queryForInt(String sql,
Map args)
Query for an int passing in a SQL query
using the named parameter support provided by the
NamedParameterJdbcTemplate
and a map containing the arguments. |
|
int |
queryForInt(String sql,
Object... args)
Query for an int passing in a SQL query
using the standard '?' |
|
int |
queryForInt(String sql,
SqlParameterSource args)
Query for an int passing in a SQL query
using the named parameter support provided by the
NamedParameterJdbcTemplate
and a SqlParameterSource containing the arguments. |
|
List<Map<String,Object>> |
queryForList(String sql,
Map args)
Execute the supplied query with the supplied arguments. |
|
List<Map<String,Object>> |
queryForList(String sql,
Object... args)
Execute the supplied query with the (optional) supplied arguments. |
|
List<Map<String,Object>> |
queryForList(String sql,
SqlParameterSource args)
Execute the supplied query with the supplied arguments. |
|
long |
queryForLong(String sql,
Map args)
Query for an long passing in a SQL query
using the named parameter support provided by the
NamedParameterJdbcTemplate
and a map containing the arguments. |
|
long |
queryForLong(String sql,
Object... args)
Query for an long passing in a SQL query
using the standard '?' |
|
long |
queryForLong(String sql,
SqlParameterSource args)
Query for an long passing in a SQL query
using the named parameter support provided by the
NamedParameterJdbcTemplate
and a SqlParameterSource containing the arguments. |
|
Map<String,Object> |
queryForMap(String sql,
Map args)
Execute the supplied query with the supplied arguments. |
|
Map<String,Object> |
queryForMap(String sql,
Object... args)
Execute the supplied query with the (optional) supplied arguments. |
|
Map<String,Object> |
queryForMap(String sql,
SqlParameterSource args)
Execute the supplied query with the supplied arguments. |
|
|
queryForObject(String sql,
Class<T> requiredType,
Map args)
Query for an object of type T identified by the supplied @Class. |
|
|
queryForObject(String sql,
Class<T> requiredType,
Object... args)
Query for an object of type T identified by the supplied @Class. |
|
|
queryForObject(String sql,
Class<T> requiredType,
SqlParameterSource args)
Query for an object of type T identified by the supplied @Class. |
|
|
queryForObject(String sql,
ParameterizedRowMapper<T> rm,
Map args)
Query for an object of type T using the supplied
ParameterizedRowMapper to the query results to the object. |
|
|
queryForObject(String sql,
ParameterizedRowMapper<T> rm,
Object... args)
Query for an object of type T using the supplied
ParameterizedRowMapper to the query results to the object. |
|
|
queryForObject(String sql,
ParameterizedRowMapper<T> rm,
SqlParameterSource args)
Query for an object of type T using the supplied
ParameterizedRowMapper to the query results to the object. |
|
int |
update(String sql,
Map args)
Execute the supplied SQL statement with (optional) supplied arguments. |
|
int |
update(String sql,
Object... args)
Execute the supplied SQL statement with supplied arguments. |
|
int |
update(String sql,
SqlParameterSource args)
Execute the supplied SQL statement with supplied arguments. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleJdbcTemplate(DataSource dataSource)
Creates a classic Spring JdbcTemplate and wraps it.
dataSource - the JDBC DataSource to accesspublic SimpleJdbcTemplate(JdbcOperations classicJdbcTemplate)
classicJdbcTemplate - the classic Spring JdbcTemplate to wrappublic SimpleJdbcTemplate(NamedParameterJdbcOperations namedParameterJdbcTemplate)
namedParameterJdbcTemplate - the Spring NamedParameterJdbcTemplate to wrap| Method Detail |
|---|
public JdbcOperations getJdbcOperations()
getJdbcOperations in interface SimpleJdbcOperationspublic NamedParameterJdbcOperations getNamedParameterJdbcOperations()
getNamedParameterJdbcOperations in interface SimpleJdbcOperations
public int queryForInt(String sql,
Map args)
throws DataAccessException
SimpleJdbcOperationsint passing in a SQL query
using the named parameter support provided by the
NamedParameterJdbcTemplate
and a map containing the arguments.
queryForInt in interface SimpleJdbcOperationssql - the SQL query to run.args - the map containing the arguments for the query.
DataAccessException
public int queryForInt(String sql,
SqlParameterSource args)
throws DataAccessException
SimpleJdbcOperationsint passing in a SQL query
using the named parameter support provided by the
NamedParameterJdbcTemplate
and a SqlParameterSource containing the arguments.
queryForInt in interface SimpleJdbcOperationssql - the SQL query to run.args - the SqlParameterSource containing the arguments for the query.
DataAccessException
public int queryForInt(String sql,
Object... args)
throws DataAccessException
SimpleJdbcOperationsint passing in a SQL query
using the standard '?' placeholders for parameters
and a variable number of arguments.
queryForInt in interface SimpleJdbcOperationssql - the SQL query to run.args - the variable number of arguments for the query.
DataAccessException
public long queryForLong(String sql,
Map args)
throws DataAccessException
SimpleJdbcOperationslong passing in a SQL query
using the named parameter support provided by the
NamedParameterJdbcTemplate
and a map containing the arguments.
queryForLong in interface SimpleJdbcOperationssql - the SQL query to run.args - the map containing the arguments for the query.
DataAccessException
public long queryForLong(String sql,
SqlParameterSource args)
throws DataAccessException
SimpleJdbcOperationslong passing in a SQL query
using the named parameter support provided by the
NamedParameterJdbcTemplate
and a SqlParameterSource containing the arguments.
queryForLong in interface SimpleJdbcOperationssql - the SQL query to run.args - the SqlParameterSource containing the arguments for the query.
DataAccessException
public long queryForLong(String sql,
Object... args)
throws DataAccessException
SimpleJdbcOperationslong passing in a SQL query
using the standard '?' placeholders for parameters
and a variable number of arguments.
queryForLong in interface SimpleJdbcOperationssql - the SQL query to run.args - the variable number of arguments for the query.
DataAccessException
public <T> T queryForObject(String sql,
Class<T> requiredType,
Map args)
throws DataAccessException
SimpleJdbcOperationsT identified by the supplied @Class.
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
queryForObject in interface SimpleJdbcOperationssql - the SQL query to run.requiredType - the required type of the return value.args - the map containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForObject(String, Class),
JdbcOperations.queryForObject(String, Object[], Class)
public <T> T queryForObject(String sql,
Class<T> requiredType,
SqlParameterSource args)
throws DataAccessException
SimpleJdbcOperationsT identified by the supplied @Class.
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
queryForObject in interface SimpleJdbcOperationssql - the SQL query to run.requiredType - the required type of the return value.args - the SqlParameterSource containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForObject(String, Class),
JdbcOperations.queryForObject(String, Object[], Class)
public <T> T queryForObject(String sql,
Class<T> requiredType,
Object... args)
throws DataAccessException
SimpleJdbcOperationsT identified by the supplied @Class.
Uses sql with the standard '?' placeholders for parameters
queryForObject in interface SimpleJdbcOperationssql - the SQL query to run.requiredType - the required type of the return value.args - the variable number of arguments for the query.
DataAccessExceptionJdbcOperations.queryForObject(String, Class),
JdbcOperations.queryForObject(String, Object[], Class)
public <T> T queryForObject(String sql,
ParameterizedRowMapper<T> rm,
Map args)
throws DataAccessException
SimpleJdbcOperationsT using the supplied
ParameterizedRowMapper to the query results to the object.
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
queryForObject in interface SimpleJdbcOperationssql - the SQL query to run.rm - the @ParameterizedRowMapper to use for result mappingargs - the map containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForObject(String, org.springframework.jdbc.core.RowMapper),
JdbcOperations.queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
public <T> T queryForObject(String sql,
ParameterizedRowMapper<T> rm,
SqlParameterSource args)
throws DataAccessException
SimpleJdbcOperationsT using the supplied
ParameterizedRowMapper to the query results to the object.
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
queryForObject in interface SimpleJdbcOperationssql - the SQL query to run.rm - the @ParameterizedRowMapper to use for result mappingargs - the SqlParameterSource containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForObject(String, org.springframework.jdbc.core.RowMapper),
JdbcOperations.queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
public <T> T queryForObject(String sql,
ParameterizedRowMapper<T> rm,
Object... args)
throws DataAccessException
SimpleJdbcOperationsT using the supplied
ParameterizedRowMapper to the query results to the object.
Uses sql with the standard '?' placeholders for parameters
queryForObject in interface SimpleJdbcOperationssql - the SQL query to run.rm - the @ParameterizedRowMapper to use for result mappingargs - the variable number of arguments for the query.
DataAccessExceptionJdbcOperations.queryForObject(String, org.springframework.jdbc.core.RowMapper),
JdbcOperations.queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
public <T> List<T> query(String sql,
ParameterizedRowMapper<T> rm,
Map args)
throws DataAccessException
SimpleJdbcOperationsList of Objects of type T using
the supplied ParameterizedRowMapper to the query results to the object.
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
query in interface SimpleJdbcOperationssql - the SQL query to run.rm - the @ParameterizedRowMapper to use for result mappingargs - the map containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForObject(String, org.springframework.jdbc.core.RowMapper),
JdbcOperations.queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
public <T> List<T> query(String sql,
ParameterizedRowMapper<T> rm,
SqlParameterSource args)
throws DataAccessException
SimpleJdbcOperationsList of Objects of type T using
the supplied ParameterizedRowMapper to the query results to the object.
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
query in interface SimpleJdbcOperationssql - the SQL query to run.rm - the @ParameterizedRowMapper to use for result mappingargs - the SqlParameterSource containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForObject(String, org.springframework.jdbc.core.RowMapper),
JdbcOperations.queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
public <T> List<T> query(String sql,
ParameterizedRowMapper<T> rm,
Object... args)
throws DataAccessException
SimpleJdbcOperationsList of Objects of type T using
the supplied ParameterizedRowMapper to the query results to the object.
Uses sql with the standard '?' placeholders for parameters
query in interface SimpleJdbcOperationssql - the SQL query to run.rm - the @ParameterizedRowMapper to use for result mappingargs - the variable number of arguments for the query.
DataAccessExceptionJdbcOperations.queryForObject(String, org.springframework.jdbc.core.RowMapper),
JdbcOperations.queryForObject(String, Object[], org.springframework.jdbc.core.RowMapper)
public Map<String,Object> queryForMap(String sql,
Map args)
throws DataAccessException
SimpleJdbcOperationsThe query is expected to be a single row query; the result row will be
mapped to a Map (one entry for each column, using the column name as the key).
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
queryForMap in interface SimpleJdbcOperationssql - the SQL query to run.args - the map containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForMap(String),
JdbcOperations.queryForMap(String, Object[])
public Map<String,Object> queryForMap(String sql,
SqlParameterSource args)
throws DataAccessException
SimpleJdbcOperationsThe query is expected to be a single row query; the result row will be
mapped to a Map (one entry for each column, using the column name as the key).
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
queryForMap in interface SimpleJdbcOperationssql - the SQL query to run.args - the SqlParameterSource containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForMap(String),
JdbcOperations.queryForMap(String, Object[])
public Map<String,Object> queryForMap(String sql,
Object... args)
throws DataAccessException
SimpleJdbcOperationsThe query is expected to be a single row query; the result row will be mapped to a Map (one entry for each column, using the column name as the key). Uses sql with the standard '?' placeholders for parameters
queryForMap in interface SimpleJdbcOperationssql - the SQL query to run.args - the variable number of arguments for the query.
DataAccessExceptionJdbcOperations.queryForMap(String),
JdbcOperations.queryForMap(String, Object[])
public List<Map<String,Object>> queryForList(String sql,
Map args)
throws DataAccessException
SimpleJdbcOperationsEach element in the returned List is constructed as a Map
as described in SimpleJdbcOperations.queryForMap(java.lang.String, java.util.Map)
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
queryForList in interface SimpleJdbcOperationssql - the SQL query to run.args - the map containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForList(String),
JdbcOperations.queryForList(String, Object[])
public List<Map<String,Object>> queryForList(String sql,
SqlParameterSource args)
throws DataAccessException
SimpleJdbcOperationsEach element in the returned List is constructed as a Map
as described in SimpleJdbcOperations.queryForMap(java.lang.String, java.util.Map)
Uses sql with the named parameter support provided by the
NamedParameterJdbcTemplate
queryForList in interface SimpleJdbcOperationssql - the SQL query to run.args - the SqlParameterSource containing the arguments for the query.
DataAccessExceptionJdbcOperations.queryForList(String),
JdbcOperations.queryForList(String, Object[])
public List<Map<String,Object>> queryForList(String sql,
Object... args)
throws DataAccessException
SimpleJdbcOperationsEach element in the returned List is constructed as a Map
as described in SimpleJdbcOperations.queryForMap(java.lang.String, java.util.Map)
Uses sql with the standard '?' placeholders for parameters
queryForList in interface SimpleJdbcOperationssql - the SQL query to run.args - the variable number of arguments for the query.
DataAccessExceptionJdbcOperations.queryForList(String),
JdbcOperations.queryForList(String, Object[])
public int update(String sql,
Map args)
throws DataAccessException
SimpleJdbcOperationsNamedParameterJdbcTemplate
update in interface SimpleJdbcOperationssql - the SQL statement to execute.args - the map containing the arguments for the query.
DataAccessExceptionNamedParameterJdbcOperations.update(String, Map)
public int update(String sql,
SqlParameterSource args)
throws DataAccessException
SimpleJdbcOperationsNamedParameterJdbcTemplate
update in interface SimpleJdbcOperationssql - the SQL statement to execute.args - the SqlParameterSource containing the arguments for the statement.
DataAccessExceptionNamedParameterJdbcOperations.update(String, SqlParameterSource)
public int update(String sql,
Object... args)
throws DataAccessException
SimpleJdbcOperations
update in interface SimpleJdbcOperationssql - the SQL statement to execute.args - the variable number of arguments for the query.
DataAccessExceptionJdbcOperations.update(String),
JdbcOperations.update(String, Object[])
public int[] batchUpdate(String sql,
List<Object[]> batchArgs)
SimpleJdbcOperations
batchUpdate in interface SimpleJdbcOperationssql - the SQL statement to execute.batchArgs - the List of Object arrays containing the batch of arguments for the query.
public int[] batchUpdate(String sql,
List<Object[]> batchArgs,
int[] argTypes)
SimpleJdbcOperations
batchUpdate in interface SimpleJdbcOperationssql - the SQL statement to execute.batchArgs - the List of Object arrays containing the batch of arguments for the query.argTypes - SQL types of the arguments
(constants from java.sql.Types)
public int[] batchUpdate(String sql,
Map[] batchValues)
SimpleJdbcOperations
batchUpdate in interface SimpleJdbcOperationssql - the SQL statement to execute.batchValues - the array of Maps containing the batch of arguments for the query.
public int[] batchUpdate(String sql,
SqlParameterSource[] batchArgs)
SimpleJdbcOperations
batchUpdate in interface SimpleJdbcOperationssql - the SQL statement to execute.batchArgs - the array of SqlParameterSource containing the batch of arguments for the query.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||