0

I am having a problem with a Java 1.4 app.

I am executing a JDBC Qyery-which is 2 date fields in an Oracle database (both the 2 fields I am reading is of type DATE with NULLABLE = false)

SELECT effFrom, effTo FROM myTable WHERE .... 

And is exceuted with a JDBCConnection

Object[][] result = JDBCConnection.getSqlObjectArray(query, bindVals); 

I get the data back in my result and loop through it

for (int i = 0; i < result.length; i++) { java.sql.Timestamp effFrom = (java.sql.Timestamp ) result[i][0]; java.sql.Timestamp effTo = (java.sql.Timestamp ) result[i][1]; 

but it fails converting the object to a java.sql.Timestamp with the error ClassCastException: Cannot cast java.sql.Date (id=9010) to java.sql.Timestamp

(java.sql.Timestamp ) result[i][0] 

So I changed the convertion to

java.sql.Date effFrom = (java.sql.Date) result[i][0]; 

And it is working. All perfect.

But the thing is that my code did not change and the data did not change for the last 6 months atleast.

It did work with the Timestamp conversion up to yesterday and today it is not working with the timestamp but with the Date.

I then went back to the source code repo and seen that it was originally java.sql.Date about 2 years ago and now I basically rolled it back. So clearly there is something that I am missing here.

Is there a way that the JDBC query could mis interpret the data type?

As per Rudi's question what is inside JDBCConnection.getSqlObjectArray()

It has a JdbcDaoSupport class called dao

 public static Object[][] getSqlObjectArray(String sql, String bind1, String bind2, String bind3) { Object[][] a = dao.getSqlObjectArrayImpl(sql, bind1, bind2, bind3); return a; } 
7
  • @Chrispie Can please attach table description Commented Dec 18, 2014 at 15:32
  • I added the following to my question (both the 2 fields I am reading is of type DATE with NULLABLE = false) Commented Dec 18, 2014 at 15:34
  • 2
    @hfontanez - Did you actually read the question before claiming it's a duplicate? Commented Dec 18, 2014 at 15:34
  • It seems to me if we're to be able to help we need to know whats inside JDBCConnection.getSqlObjectArray() and which data types your effFrom and effTo columns are inside your DB. Commented Dec 18, 2014 at 15:51
  • Have you changed the jdbc driver? Commented Dec 18, 2014 at 16:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.