日期:2014-05-20  浏览次数:20790 次

求JdbcTemplate().queryForList()方法各参数的详解
求JdbcTemplate.queryForList()方法各不同参数的详解

------解决方案--------------------
HTML code
queryForList 
public List queryForList(String sql,
            Object[] args,
            int[] argTypes,
            Class elementType)
        throws DataAccessExceptionDescription copied from interface: JdbcOperations
Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list.
The results will be mapped to a List (one entry for each row) of result objects, each of them matching the specified element type.


Specified by:
queryForList in interface JdbcOperations
Parameters:
sql - SQL query to execute
args - 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)
elementType - the required type of element in the result list (for example, Integer.class)
Returns:
a List of objects that match the specified element type
Throws:
DataAccessException - if the query fails
See Also:
JdbcOperations.queryForList(String, Class), SingleColumnRowMapper

--------------------------------------------

queryForList
public List queryForList(String sql,
            Object[] args,
            Class elementType)
        throws DataAccessExceptionDescription copied from interface: JdbcOperations
Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list.
The results will be mapped to a List (one entry for each row) of result objects, each of them matching the specified element type.


Specified by:
queryForList in interface JdbcOperations
Parameters:
sql - SQL query to execute
args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type)
elementType - the required type of element in the result list (for example, Integer.class)
Returns:
a List of objects that match the specified element type
Throws:
DataAccessException - if the query fails
See Also:
JdbcOperations.queryForList(String, Class), SingleColumnRowMapper

--------------------------------------------

queryForList
public List queryForList(String sql,
            Object[] args,
            int[] argTypes)
        throws DataAccessExceptionDescription copied from interface: JdbcOperations
Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list.
The results will be mapped to a List (one entry for each row) of Maps (one entry for each column, using the column name as the key). Thus Each element in the list will be of the form returned by this interface's queryForMap() methods.


Specified by:
queryForList in interface JdbcOperations
Parameters:
sql - SQL query to execute
args - 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)
Returns:
a List that contains a Map per row
Throws:
DataAccessException - if the query fails
See Also:
JdbcOperations.queryForList(String), Types