2014年1月份 流水帐
protected Timestamp getOracleTimestamp(Object val){Class c = val.getClass();Timestamp time = null;try {Method method = c.getMethod("timestampValue", null);time = (Timestamp)method.invoke(val, null);} catch (Exception e) {e.printStackTrace();} return time; }
?M2:查询时处理成java.util.Date类型
public List doQueryForGroup(String sql,Object[] params,int columnNum,int[] dateColIndexs)throws AppException{Connection conn = null;PreparedStatement pstmt = null;ResultSet rs = null;List rsls = new ArrayList();try{conn = getConnection(); pstmt = conn.prepareStatement(sql); if(params!=null&¶ms.length>0){ for(int i=1;i<=params.length;i++) pstmt.setObject(i, params[i-1]); } rs = pstmt.executeQuery(); while(rs.next()){ Object[] objs = new Object[columnNum]; for(int i=1;i<=columnNum;i++){ if(this.isContains(i, dateColIndexs)){ //objs[i-1] = (java.util.Date)rs.getDate(i); 返回日期,无时间 objs[i-1] = (java.util.Date)rs.getTimestamp(i); }else{ objs[i-1] = rs.getObject(i); } } rsls.add(objs); }}catch(Exception e){logger.error("do query error"+e);e.printStackTrace();throw new AppException(e);}finally{close(rs, pstmt, conn);}return rsls;}
?
?
2、