【发布时间】:2014-09-17 13:47:45
【问题描述】:
我收到以下代码 sn-ps 的以下给定错误:
try {
cRows = new CachedRowSetImpl();
while(cRows.next())
{
MyClass myClass = new MyClass();
myClass.setPrevDate(cRows.getDate("PREV_DATE")); // In debug mode, the error was throwing when I press Resume from here.
}
}
错误:
Caused by: java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.sql.Date
在数据库中,列的数据类型仅为DATE。我不知道Timestamp 是从哪里来的。
【问题讨论】:
-
给我你的完整课程,然后我可以帮助你
-
我们需要看一下CachedRowSetImpl和MyClass的代码。
-
这有帮助吗
http://stackoverflow.com/questions/20130129/error-java-sql-timestamp-cannot-be-cast-to-java-sql-date-in-jfreechart -
@BrunoFranco:
CachedRowSetImpl来自import com.sun.rowset.CachedRowSetImpl; -
@Abhi:这对我不起作用。我的列的值为
18-09-14,类型为DATE。
标签: java classcastexception cachedrowset