Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
131 views
in Technique[技术] by (71.8m points)

java - ResultSet#getDate() semantics

We migrated from to ojdbc6-11.2.0.3.0 to ojdbc7-12.1.0.1 and observed a change in the ResultSet#getDate() semantics. Previously the java.sql.Date returned would be 'normalized' by having set the hours, minutes, seconds and milliseconds to zero according to the contract specified on java.sql.Date. With ojdbc7this is no longer the case and java.sql.Date has the hours, minutes, seconds and milliseconds set according to the value on the database.

I looked at the Javadoc of ResultSet#getDate() and it doesn't explicitly say which of the behaviors is the correct one. I would have assumed the old behavior was what the specification intended. Am I right? Have we encountered a driver bug?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is clearly a bug as the documentation of the class java.sql.Date states

To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...