public class SpartaJdbcTemplate
extends org.springframework.jdbc.core.JdbcTemplate
| Constructor and Description |
|---|
SpartaJdbcTemplate()
Construct a new SpartaJdbcTemplate for bean usage.
|
SpartaJdbcTemplate(DataSource dataSource)
Construct a new SpartaJdbcTemplate, given a DataSource to obtain connections from.
|
SpartaJdbcTemplate(DataSource dataSource,
boolean lazyInit)
Construct a new SpartaJdbcTemplate, given a DataSource to obtain connections from.
|
| Modifier and Type | Method and Description |
|---|---|
<T> Optional<T> |
queryForOptionalObject(String sql,
Class<T> requiredType)
Execute a query for a result object (optional), given static SQL.
|
<T> Optional<T> |
queryForOptionalObject(String sql,
Class<T> requiredType,
Object... args)
Query given SQL to create a prepared statement from SQL and a
list of arguments to bind to the query, expecting a result object (optional).
|
<T> Optional<T> |
queryForOptionalObject(String sql,
Object[] args,
Class<T> 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 (optional).
|
<T> Optional<T> |
queryForOptionalObject(String sql,
Object[] args,
int[] argTypes,
Class<T> 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 (optional).
|
<T> Optional<T> |
queryForOptionalObject(String sql,
Object[] args,
int[] argTypes,
org.springframework.jdbc.core.RowMapper<T> 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.
|
<T> Optional<T> |
queryForOptionalObject(String sql,
Object[] args,
org.springframework.jdbc.core.RowMapper<T> 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.
|
<T> Optional<T> |
queryForOptionalObject(String sql,
org.springframework.jdbc.core.RowMapper<T> rowMapper)
Execute a query given static SQL, mapping a single result row to a Java
object via a RowMapper.
|
<T> Optional<T> |
queryForOptionalObject(String sql,
org.springframework.jdbc.core.RowMapper<T> rowMapper,
Object... args)
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.
|
applyStatementSettings, batchUpdate, batchUpdate, batchUpdate, batchUpdate, batchUpdate, call, createConnectionProxy, createResultsMap, execute, execute, execute, execute, execute, execute, execute, extractOutputParameters, extractReturnedResults, getColumnMapRowMapper, getFetchSize, getMaxRows, getNativeJdbcExtractor, getQueryTimeout, getSingleColumnRowMapper, handleWarnings, handleWarnings, isIgnoreWarnings, isResultsMapCaseInsensitive, isSkipResultsProcessing, isSkipUndeclaredResults, newArgPreparedStatementSetter, newArgTypePreparedStatementSetter, processResultSet, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, queryForList, queryForList, queryForList, queryForList, queryForList, queryForList, queryForList, queryForMap, queryForMap, queryForMap, queryForObject, queryForObject, queryForObject, queryForObject, queryForObject, queryForObject, queryForObject, queryForObject, queryForRowSet, queryForRowSet, queryForRowSet, setFetchSize, setIgnoreWarnings, setMaxRows, setNativeJdbcExtractor, setQueryTimeout, setResultsMapCaseInsensitive, setSkipResultsProcessing, setSkipUndeclaredResults, update, update, update, update, update, update, updatepublic SpartaJdbcTemplate()
Note: The DataSource has to be set before using the instance.
JdbcAccessor.setDataSource(javax.sql.DataSource)public SpartaJdbcTemplate(DataSource dataSource)
Note: This will not trigger initialization of the exception translator.
dataSource - the JDBC DataSource to obtain connections frompublic SpartaJdbcTemplate(DataSource dataSource, boolean lazyInit)
Note: 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 SQLExceptionTranslatorpublic <T> Optional<T> queryForOptionalObject(String sql, Class<T> requiredType) throws org.springframework.dao.DataAccessException
Uses a JDBC Statement, not a PreparedStatement. If you want to
execute a static query with a PreparedStatement, use the overloaded
queryForOptionalObject(String, Class, Object...) method with
null as argument array.
This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query; the returned result will be directly mapped to the corresponding object type.
T - type of class to generate the responsesql - SQL query to executerequiredType - the type that the result object is expected to matchorg.springframework.dao.DataAccessException - if there is any problem executing the queryqueryForOptionalObject(String, Object[], Class)public <T> Optional<T> queryForOptionalObject(String sql, Class<T> requiredType, Object... args) throws org.springframework.dao.DataAccessException
The query is expected to be a single row/single column query; the returned result will be directly mapped to the corresponding object type.
T - Type of the object to be returnedsql - SQL query to executerequiredType - the type that the result object is expected to matchargs - arguments to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type);
may also contain SqlParameterValue objects which indicate not
only the argument value but also the SQL type and optionally the scaleorg.springframework.dao.DataAccessException - if the query failsqueryForOptionalObject(String, Class)public <T> Optional<T> queryForOptionalObject(String sql, Object[] args, Class<T> requiredType) throws org.springframework.dao.DataAccessException
The query is expected to be a single row/single column query; the returned result will be directly mapped to the corresponding object type.
T - Type of the object to be returnedsql - SQL query to executeargs - arguments to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type);
may also contain SqlParameterValue objects which indicate not
only the argument value but also the SQL type and optionally the scalerequiredType - the type that the result object is expected to matchorg.springframework.dao.DataAccessException - if the query failsqueryForOptionalObject(String, Class)public <T> Optional<T> queryForOptionalObject(String sql, Object[] args, int[] argTypes, Class<T> requiredType) throws org.springframework.dao.DataAccessException
The query is expected to be a single row/single column query; the returned result will be directly mapped to the corresponding object type.
T - Type of the object to be returnedsql - SQL query to executeargs - arguments to bind to the queryargTypes - SQL types of the arguments
(constants from java.sql.Types)requiredType - the type that the result object is expected to matchorg.springframework.dao.DataAccessException - if the query failsqueryForOptionalObject(String, Class),
Typespublic <T> Optional<T> queryForOptionalObject(String sql, Object[] args, int[] argTypes, org.springframework.jdbc.core.RowMapper<T> rowMapper) throws org.springframework.dao.DataAccessException
T - Type of the object to be returnedsql - SQL query to executeargs - arguments to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type)argTypes - SQL types of the arguments
(constants from java.sql.Types)rowMapper - object that will map one object per roworg.springframework.dao.DataAccessException - if the query failspublic <T> Optional<T> queryForOptionalObject(String sql, Object[] args, org.springframework.jdbc.core.RowMapper<T> rowMapper) throws org.springframework.dao.DataAccessException
T - Type of the object to be returnedsql - SQL query to executeargs - arguments to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type);
may also contain SqlParameterValue objects which indicate not
only the argument value but also the SQL type and optionally the scalerowMapper - object that will map one object per roworg.springframework.dao.DataAccessException - if the query failspublic <T> Optional<T> queryForOptionalObject(String sql, org.springframework.jdbc.core.RowMapper<T> rowMapper) throws org.springframework.dao.DataAccessException
Uses a JDBC Statement, not a PreparedStatement. If you want to
execute a static query with a PreparedStatement, use the overloaded
queryForOptionalObject(String, RowMapper, Object...) method with
null as argument array.
T - Type of the object to be returnedsql - SQL query to executerowMapper - object that will map one object per roworg.springframework.dao.DataAccessException - if there is any problem executing the queryqueryForOptionalObject(String, Object[], RowMapper)public <T> Optional<T> queryForOptionalObject(String sql, org.springframework.jdbc.core.RowMapper<T> rowMapper, Object... args) throws org.springframework.dao.DataAccessException
T - Type of the object to be returned
(leaving it to the PreparedStatement to guess the corresponding SQL type);
may also contain SqlParameterValue objects which indicate not
only the argument value but also the SQL type and optionally the scalesql - SQL query to executerowMapper - object that will map one object per rowargs - arguments to bind to the queryorg.springframework.dao.DataAccessException - if the query failsCopyright © 2015. All rights reserved.