Question

We just switched from ojdbc14 to ojdbc6, and noticed that when we insert a javax.sql.Time value into an Oracle column via a prepared statement and preparedStatement.setTime(1, new javax.sql.Time(new Date().getTime())), its behavior changed. It used to insert both Date and Time information into the table, but with the new driver, it appears that only the Time portion is captured, and the values we see in the database are dated with Jan 1, 1970.

Now, it is pretty obvious that this is the case, my question is where I can find an official document or change note that describes this behavior.

Thanks

Was it helpful?

Solution

In my opinion it would better serve you by passing values as date/time objects, such as java.sql.Timestamp, and reading them as such. So you would use public void setTimestamp(int parameterIndex, Timestamp x) to set the respective values. This is much cleaner to use.

You can then use Java SimpleDateFormat to format the data to your own liking after you have read it from the database.

There are however some documented bugs with timestamp usage that you can find in this Oracle JDBC Driver Documentation. These might not be directly relevant to you but look at the following ones: #BUG-6749320, #6870832, #7028625, #6441084

You might want to read about the change over here: "What is going on with DATE and TIMESTAMP?" provided in the Oracle JDBC FAQ section.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top