Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Problem extracting Oracle Timestamp with SQLRowset [SPR-4886] #9562
I extract data from an Oracle Database using org.springframework.jdbc.core.JdbcTemplate.
If I try to extract data from timestamp columns, I get a ClassCastException, because the template gets an oracle.sql.TIMESTAMP object instead of a java.sql.Timestamp.
SqlRowSet rs = _jdbcTemplate.queryForRowSet("SELECT FFNACPER FROM TEMP_ALPER");
To make it work, I must get an object, and convert it manually:
oracle.sql.TIMESTAMP timestamp = (oracle.sql.TIMESTAMP) rs.getObject("FFNACPER");
It also works ok, if I use a ResultSetExtractor instead of an SqlRowSet
Have tested only for timestamp. Haven't tried with rs.getDate, or rs.getTime
1 votes, 2 watchers
Richard Kettelerij commented
I'm facing a similair issue. In my case the exception is thrown from queryForRowSet(), instead of the getTimestamp() method.
The exception says "Invalid SQL type for column". This due to the timestamp column in my table which is defined as "TIMESTAMP(6) WITH LOCAL TIME". The "with local time" part isn't recognized as a valid type by Sun's CachedRowSetImpl. Perhaps this can also be taken into account when fixing (or working around) this issue in Spring 3.0?