JdbcTemplate.queryForList()方法各不同参数的详解
2015-06-28 16:33
603 查看
public <T> List<T> queryForList( String sql, Class<T> elementType, Object... args )throws DataAccessException
官方文档解释:
Parameters:
sql - SQL query to execute
elementType - the required type of element in the result list (for example, Integer.class)
args - 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 scale
我的理解
String sql, // 查询用的sql句
Object[] args, // sql句中的参数
int[] argTypes, // sql句中的参数的数据类型(java类型)
Class elementType // list装载结果的元数据类型
官方文档中最后的一个开变参数中讲到最后一个参数中可以包含SqlParameterValue对象,也就是说如果要通过这种方式给sql语句传参数,要将参数的类型转换成Object类型,如使用 Object[]{参数}这种方法
相关文章推荐
- HDU 5273 Dylans loves sequence【 树状数组 】
- 杭电ACM1297——Children’s Queue~~大数相加的应用
- Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools
- 杭电1005 Number Sequence
- iOS UITabBarItem 选中图的颜色,设置UIimage的渲染模式
- Android Volley完全解析(三),定制自己的Request
- UIImageView传值与生命周期的关系
- 用arduino做一个简单的计算器
- 解决SDCycleScrollView组建遇到UINavigationController时图片位置不准确
- hdu 1242 Rescue
- ArrayBlockingQueue源码剖析
- VirtualBox下快速创建新的虚拟机(一)——复制vdi文件
- Word Frequency
- APUE 头文件apue.h 解决方法
- Java常见的queue(队列)类测试
- 【Arduino学习笔记】蓝牙控制手自两用避障车
- 在jfinal中使用druid,并配置查看权限
- LeetCode_60---Permutation Sequence
- 如果分配给命令的连接位于本地挂起事务中,ExecuteNonQuery 要求命令拥有事务。命令的 Transaction 属性尚未初始化
- [安卓]手机管家(二十一)杀毒UI及SlidingDrawer(抽屉效果)