求JdbcTemplate().queryForList()方法各参数的详解
求JdbcTemplate.queryForList()方法各不同参数的详解
[解决办法]
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
--------------------------------------------
queryForList
public List queryForList(String sql,
Object[] args)
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). 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)
Returns:
a List that contains a Map per row
Throws:
DataAccessException - if the query fails
See Also:
JdbcOperations.queryForList(String)
public List queryForList(String sql, // 查询用的sql句 Object[] args, // sql句中的预处理参数 int[] argTypes, // 参数的类型,取自于java.sql.Types Class elementType) // 在结果列表中的参数类型,例如Integer.Class
[解决办法]
public List queryForList(String sql, //sql 语句
Object[] args, //sql中参数,用数组对应
Class elementType) //对应Bean包装结果
[解决办法]
#7楼 的你也太自大了吧
我就喜欢这么问问题
现在我纯靠技术年薪15万
当然了你也可以说我机缘巧合走了运
但是你不会也怀疑肯于给出这样待遇的公司的人事和考官的眼光和择人标准吧
技术多了去了 每样都去细学你学的完吗?
我更想明白的说:你 是 傻 B
[解决办法]
String sql, // 查询用的sql句
Object[] args, // sql句中的参数
int[] argTypes, // sql句中的参数的数据类型(java类型)
Class elementType) // list装载结果的元数据类型