我目前正在使用 Spring 框架,但我不确定这是否是直接的问题。我收到以下错误:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.sql.Date
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:929)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:824)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:798)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
@SuppressWarnings({ "rawtypes", "unchecked"})
public List getAllByFilter( String collectionPeriod,String sYear, String submission) {
// TODO Auto-generated method stub SELECT_QUERY_BY_COLL_MSTR
List<CollectionCalendar> orgs1 = new ArrayList<CollectionCalendar>();
List<Map<String,Object>> rows1 = null;
String query="SELECT_QUERY_BY_COLL_MSTR";
if("All".equalsIgnoreCase(sYear) && "All".equalsIgnoreCase(collectionPeriod)){
query="SELECT_QUERY_BY_COLL_MSTR_SUBMISSION";
rows1 = getJdbcTemplate().queryForList(p.getProperty(query),new Object[] {submission});
}else if(!"All".equalsIgnoreCase(sYear) && "All".equalsIgnoreCase(collectionPeriod)){
query="SELECT_QUERY_BY_COLL_MSTR_SUBMISSION_YEAR";
rows1 = getJdbcTemplate().queryForList(p.getProperty(query),new Object[] {sYear,submission});
}else if("All".equalsIgnoreCase(sYear) && !"All".equalsIgnoreCase(collectionPeriod)){
query="SELECT_QUERY_BY_COLL_MSTR_SUBMISSION_COLLECTION";
rows1 = getJdbcTemplate().queryForList(p.getProperty(query),new Object[] {collectionPeriod,submission});
}else if(!"All".equalsIgnoreCase(sYear) && !"All".equalsIgnoreCase(collectionPeriod)){
rows1 = getJdbcTemplate().queryForList(p.getProperty(query),new Object[] {sYear,collectionPeriod,submission});
}
System.out.println("hellooooooooooooooooooo");
for (Map row : rows1) {
System.out.println("row------"+row);
CollectionCalendar collectionCalendar = new CollectionCalendar(row.get("COLL_KEY").toString(),
(Date)row.get("COLL_OPEN_DT"),
(Date)row.get("COLL_CLOSE_DT"),
(Date)row.get("COLL_AVLBL_DT"),
row.get("COLL_ACAD_YR").toString(),
row.get("COLL_NAME").toString(),
row.get("COLL_DESC").toString(),
row.get("SUBM_DESC").toString(),
row.get("UPDATE_USER").toString());
//(Timestamp) row.get("UPDATE_DTTM"));
orgs1.add(collectionCalendar); (COMMENTED THIS OUT BUT STILL GETTING ERROR)
}
return orgs1;
}
public CollectionCalendar(String colKey,Date opDate,Date clDate,Date avDate,String sYear,String submission,String collectionPeriod,String subDesc,String updateUser){
setCollKey(colKey);
setOpenDate(opDate);
setCloseDate(clDate);
setAvailDate(avDate);
setsYear(sYear);
setSubmission(submission);
setCollectionPeriod(collectionPeriod);
setSubDesc(subDesc);
setUpdateUser(updateUser);
//setUpdateTime(updateTime);
}
我拥有的是一个查询数据库并将结果返回到表中的搜索表单。我正在从列类型所在的 Oracle DB 表中提取数据,Date
但由于某种原因,它告诉我它不能从Timestamp
值中转换。我根本不要求Timestamp
价值。
任何帮助是极大的赞赏。