大虾们,快点过来瞅瞅,搞的头都大了.关于ORA-01858的问题.在线等
这是代码:
public Page pageCount(Page page,String userName,String startDate,String endDate,String deptid){
String sql="select sum(cnt) from (select count(*) as cnt from t_humn_leave where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? " +
" union select count(*) from t_humn_overtime where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? " +
" union select count(*) from t_humn_training where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? )";
Query queryCount= getSession().createSQLQuery(sql);
queryCount.setParameter(0, "'%"+userName+"%'");
queryCount.setParameter(1, "to_date("+startDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(2, "to_date("+endDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(3, "'%"+userName+"%'");
queryCount.setParameter(4, "to_date("+startDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(5, "to_date("+endDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(6, "'%"+userName+"%'");
queryCount.setParameter(7, "to_date("+startDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(8, "to_date("+endDate+", 'yyyy-mm-dd hh24:mi:ss')");
Object count =queryCount.uniqueResult();
//Query query = getSession().createSQLQuery(sql).addEntity(entityClass);
//query.list();
String sql1="select '请假',DEPTID,USERID,STARTDATE,ENDDATE,RECORDER,REMARK,ID from t_humn_leave where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? " +
"union select '加班',DEPTID,USERID,startDate,endDate,RECORDER,REMARK,ID from t_humn_overtime where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? " +
" union select '外出培训',DEPTID,USERID,startDate,endDate,RECORDER,REMARK,ID from t_humn_training where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? ";
Query query=getSession().createSQLQuery(sql1);
query.setParameter(0, "%"+userName+"%");
query.setParameter(1, "to_date('"+startDate+"', 'yyyy-mm-dd')");
query.setParameter(2, "to_date('"+endDate+"', 'yyyy-mm-dd')");
query.setParameter(3, "%"+userName+"%");
query.setParameter(4, "to_date('"+startDate+"', 'yyyy-mm-dd')");
query.setParameter(5, "to_date('"+endDate+"', 'yyyy-mm-dd')");
query.setParameter(6, "%"+userName+"%");
query.setParameter(7, "to_date('"+startDate+"', 'yyyy-mm-dd')");
query.setParameter(8, "to_date('"+endDate+"', 'yyyy-mm-dd')");
System.out.println("三表总记录条数"+count);
List list = query.list();
page.setResult(list);
page.setTotalCount(((Number)count).longValue());
return page;
}
这是错误:
2012-04-06 15:04:13,953 [http-8686-6] WARN [org.hibernate.util.
JDBCExceptionReporter] - SQL Error: 1858, SQLState: 22008
2012-04-06 15:04:13,953 [http-8686-6] ERROR [org.hibernate.util.JDBCExceptionReporter] - ORA-01858: 在要求输入数字处找到非数字字符
2012-04-06 15:05:02,109 [http-8686-6] ERROR [500.jsp] -
could not execute query
使用httpclient抓去数据,被服务器屏蔽,connection reset解决思路