当前位置: 代码迷 >> J2EE >> nested exception is java.sql.SQLException: ORA-01008: 并非所有变量都已绑定,该如何处理
  详细解决方案

nested exception is java.sql.SQLException: ORA-01008: 并非所有变量都已绑定,该如何处理

热度:873   发布时间:2016-04-17 23:28:41.0
nested exception is java.sql.SQLException: ORA-01008: 并非所有变量都已绑定

/**
 * WEBOPAC_读者空间_借阅管理_查看借阅信息_当前借阅信息
 * @param readerId
 * @param lendStatus
 * @return
 */
public Page<WebOpacQueryVo> queryReaderLendRecordForTwo(Long readerId,
Integer lendStatus,Pageable pageable) {
StringBuilder sql=new StringBuilder();
MapSqlParameterSource paramSource = new MapSqlParameterSource();
StringBuilder countSql=new StringBuilder();
sql.append("select t.id,t.collection_id,c.status from READER_LEND_RECORD t , collection c where c.id = t.collection_id and t.reader_id =:readerId");
paramSource.addValue("readerId", readerId);
sql.append(" and t.status =:lendStatus");
paramSource.addValue("lendStatus", lendStatus);
System.out.println("WEBOPAC_读者空间_借阅管理_查看借阅信息_当前借阅信息  sql:" + sql);
countSql.append("select count(*) from ("+ sql +")");
Page<WebOpacQueryVo> page = JdbcPaginationHelper.queryForPage(namedJdbcTemplate, pageable, sql.toString(), countSql.toString(), new RowMapper<WebOpacQueryVo>(){
public WebOpacQueryVo mapRow(ResultSet rs, int rowNum)
throws SQLException {
WebOpacQueryVo woqv = new WebOpacQueryVo();
woqv.setCollection(collectionDao.findOne(rs.getLong("collection_id")));
woqv.setCollectionStatus(sysDicDao.findByTypeAndKey(Constant.COLLECTION_STATUS, rs.getInt("status")));
woqv.setReaderLendRecord(readerLendRecordDao.findOne(rs.getLong("id")));
return woqv;
}});
return page;
}


打印出的sql 

WEBOPAC_读者空间_借阅管理_查看借阅信息_当前借阅信息  sql:


select t.id,t.collection_id,c.status from READER_LEND_RECORD t , collection c where c.id = t.collection_id and t.reader_id =:readerId and t.status =:lendStatus

readerId=921 和 lendStatus=2 debug的时候都不为空 

看了半天看不出什么问题?
难道整个下午要葬送在这个问题上?

------解决思路----------------------
执行的时候paramSource参数没传进去
  相关解决方案