java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp

后端 未结 7 1179
梦谈多话
梦谈多话 2020-12-29 04:39

I am working on an application that streams ResultSet over a network. I ended up using a CachedRowSetImpl class. But when I connect to an Oracle DB, I get an error like this

7条回答
  •  被撕碎了的回忆
    2020-12-29 04:59

    I think the problem is your setLastUpdate is expecting an object of java.sql.Date type.

    Now when you use agent.setLastUpdate(res.getDate(3));

    The res.getDate(3) must be returning an object that your method doesn't expect so your there may be ClassCastException for that.

    Try this code and see whether it solves your problem or not:

    agent.setLastUpdate(new java.util.Date(res.getDate(3).getTime()));
    

提交回复
热议问题