org.springframework.dao package.
Code using this class need only implement callback interfaces, giving
them a clearly defined contract. The callback
interface creates a prepared statement given a Connection, providing SQL and
any necessary parameters. The PreparedStatementCreator interface extracts
values from a ResultSet. See also ResultSetExtractor and
PreparedStatementSetter for two popular alternative callback interfaces.
RowMapper
Can be used within a service implementation via direct instantiation with a DataSource reference, or get prepared in an application context and given to services as bean reference. Note: The DataSource should always be configured as a bean in the application context, in the first case given to the service directly, in the second case to the prepared template.
Because this class is parameterizable by the callback interfaces and
the
interface, there should be no need to subclass it.
org.springframework.jdbc.support.SQLExceptionTranslator
All SQL operations performed by this class are logged at debug level, using "org.springframework.jdbc.core.JdbcTemplate" as log category.
PreparedStatementCreatorPreparedStatementSetterCallableStatementCreatorPreparedStatementCallbackCallableStatementCallbackResultSetExtractorRowCallbackHandlerRowMapperorg.springframework.jdbc.support.SQLExceptionTranslatorNote: Depending on the "lazyInit" flag, initialization of the exception translator will be triggered.
dataSource the JDBC DataSource to obtain connections fromlazyInit whether to lazily initialize the SQLExceptionTranslatorDefault is 0, indicating to use the JDBC driver's default.
java.sql.Statement.setFetchSize(int)Default is 0, indicating to use the JDBC driver's default.
java.sql.Statement.setMaxRows(int)Default is 0, indicating to use the JDBC driver's default.
Note: Any timeout specified here will be overridden by the remaining transaction timeout when executing within a transaction that has a timeout specified at the transaction level.
execute method.
The proxy also prepares returned JDBC Statements, applying statement settings such as fetch size, max rows, and query timeout.
con the JDBC Connection to create a proxy forjava.sql.Connection.close()execute(org.springframework.jdbc.core.ConnectionCallback)applyStatementSettings(java.sql.Statement)public <T> Tquery(final String sql, final ResultSetExtractor<T> rse) throws DataAccessException {
public <T> Texecute(String sql, PreparedStatementCallback<T> action) throws DataAccessException {
psc Callback handler that can create a PreparedStatement given a
Connectionpss object that knows how to set values on the prepared statement.
If this is null, the SQL will be assumed to contain no bind parameters.rse object that will extract results.org.springframework.dao.DataAccessException if there is any problemPreparedStatementCreator psc, final PreparedStatementSetter pss, final ResultSetExtractor<T> rse)
public <T> Tquery(PreparedStatementCreator psc, ResultSetExtractor<T> rse) throws DataAccessException {
public <T> Tquery(String sql, PreparedStatementSetter pss, ResultSetExtractor<T> rse) throws DataAccessException {
public <T> Tquery(String sql, Object[] args, int[] argTypes, ResultSetExtractor<T> rse) throws DataAccessException {
public <T> Tquery(String sql, Object[] args, ResultSetExtractor<T> rse) throws DataAccessException {
public <T> Tquery(String sql, ResultSetExtractor<T> rse, Object... args) throws DataAccessException {
public voidquery(PreparedStatementCreator psc, RowCallbackHandler rch) throws DataAccessException {
public voidquery(String sql, PreparedStatementSetter pss, RowCallbackHandler rch) throws DataAccessException {
public voidquery(String sql, Object[] args, int[] argTypes, RowCallbackHandler rch) throws DataAccessException {
public voidquery(String sql, Object[] args, RowCallbackHandler rch) throws DataAccessException {
public voidquery(String sql, RowCallbackHandler rch, Object... args) throws DataAccessException {
public <T> List<T>query(PreparedStatementCreator psc, RowMapper<T> rowMapper) throws DataAccessException {
public <T> List<T>query(String sql, PreparedStatementSetter pss, RowMapper<T> rowMapper) throws DataAccessException {
public <T> List<T>query(String sql, Object[] args, int[] argTypes, RowMapper<T> rowMapper) throws DataAccessException {
public <T> List<T>query(String sql, Object[] args, RowMapper<T> rowMapper) throws DataAccessException {
public <T> List<T>query(String sql, RowMapper<T> rowMapper, Object... args) throws DataAccessException {
public <T> TqueryForObject(String sql, Object[] args, RowMapper<T> rowMapper) throws DataAccessException {
public <T> TqueryForObject(String sql, RowMapper<T> rowMapper, Object... args) throws DataAccessException {
public <T> TqueryForObject(String sql, Object[] args, Class<T> requiredType) throws DataAccessException {
public <T> TqueryForObject(String sql, Class<T> requiredType, Object... args) throws DataAccessException {
public Map<String, Object>queryForMap(String sql, Object[] args, int[] argTypes) throws DataAccessException {
public longqueryForLong(String sql, Object[] args, int[] argTypes) throws DataAccessException {
public <T> List<T>queryForList(String sql, Object[] args, int[] argTypes, Class<T> elementType) throws DataAccessException {
public <T> List<T>queryForList(String sql, Object[] args, Class<T> elementType) throws DataAccessException {
public <T> List<T>queryForList(String sql, Class<T> elementType, Object... args) throws DataAccessException {
public List<Map<String, Object>>queryForList(String sql, Object[] args, int[] argTypes) throws DataAccessException {
public List<Map<String, Object>>queryForList(String sql, Object... args) throws DataAccessException {
public SqlRowSetqueryForRowSet(String sql, Object[] args, int[] argTypes) throws DataAccessException {
logger.debug("SQL update affected " + rows + " rows and returned " + generatedKeys.size() + " keys");
public int[]batchUpdate(String sql, final BatchPreparedStatementSetter pss) throws DataAccessException {
public <T> Texecute(String callString, CallableStatementCallback<T> action) throws DataAccessException {
public Map<String, Object>call(CallableStatementCreator csc, List<SqlParameter> declaredParameters)
returnedResults.putAll(extractReturnedResults(cs, updateCountParameters, resultSetParameters, updateCount));
cs JDBC wrapper for the stored procedureupdateCountParameters Parameter list of declared update count parameters for the stored procedureresultSetParameters Parameter list of declared resturn resultSet parameters for the stored procedureSqlReturnResultSet undeclaredRsParam = new SqlReturnResultSet(rsName, new ColumnMapRowMapper());
protected Map<String, Object>extractOutputParameters(CallableStatement cs, List<SqlParameter> parameters)
protected Map<String, Object>processResultSet(ResultSet rs, ResultSetSupportingSqlParameter param) throws SQLException {