jdbcTemplate.queryForInt()过时替换方法
2018-03-23 15:38
567 查看
代替的方法为queryForObject(String sql, Object[] args, Class<T> requiredType)。
需要返回的是什么类型,就在第三个参数写什么类型。比如int类型就写Integer.class, long类型就写Long.class.
下面这种写法报错,必须传入完整包名:
需要返回的是什么类型,就在第三个参数写什么类型。比如int类型就写Integer.class, long类型就写Long.class.
String sqlStr = "select count(*) from t_user where user_name=? and password=?"; int count = jdbcTemplate.queryForObject(sqlStr,new java.lang.Object[]{userName,password},Integer.class);
下面这种写法报错,必须传入完整包名:
String sqlStr = "select count(*) from t_user where user_name=? and password=?"; return jdbcTemplate.queryForObject(sqlStr,new Object[]{userName,password},Integer.class);
相关文章推荐
- spring 3.2.2后 jdbcTemplate.queryForInt()方法过时的处理办法
- jdbcTemplate.queryForInt()方法过时的处理办法
- Spring中JDBCTemplate使用queryForObject方法时 ”Incorrect column count: expected 1, actual 5“错误
- JdbcTemplate.queryForList()方法各不同参数的详解
- 运行maven项目报错:The method queryForInt(String) is undefined for the type JdbcTemplate
- org.springframework.jdbc.core.simple.SimpleJdbcTemplate queryForMap 方法在查询结果为空时抛出异常
- jdbcTemplate.queryForObject 方法注意
- JdbcTemplate的queryForMap方法报错
- Spring中使用JdbcTemplate的queryForObject方法,当查不到数据时会抛出如下异常:
- Spring中使用JdbcTemplate的queryForObject方法,当查不到数据时会抛出如下异常:
- Spring jdbcTemplate.queryForInt(sql)的奇怪问题,呵呵
- 在使用Spring中jdbcTemplate的QueryForObject()方法时异常:EmptyResultDataAccessException
- 关于mysql 数据库使用spring 2.0低版本 JdbcTemplate.queryForList 查询结果别名不起作用的解决方法
- 2015061204 - jdbctemplate中的queryForIntf方法
- JdbcTemplate的queryForMap方法报错
- JdbcTemplate.queryForList()方法各不同参数的详解
- JdbcTemplate中的exectue和queryForList方法的性能对比
- sizeWithFont方法过时替换
- tensorflow 用矩阵运算替换for循环 用tf.tile而不写for的方法
- 通过iBatis的queryForMap方法比较resultClass与resultMap