ResultSet#getDate()语义 [英] ResultSet#getDate() semantics

查看:176
本文介绍了ResultSet#getDate()语义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们从 ojdbc6-11.2.0.3.0 迁移到 ojdbc7-12.1.0.1 并观察到更改在 ResultSet#getDate()语义。以前,根据 java.sql.Date 将被归一化 > java.sql.Date 。使用 ojdbc7 这不再是这样, java.sql.Date 设置了小时,分钟,秒和毫秒根据数据库上的值。

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.

我看了 ResultSet#getDate()的Javadoc,它没有不明确说哪些行为是正确的。我会假设旧的行为是规范的意图。我对吗?我们是否遇到驱动程序错误?

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?

推荐答案

这显然是一个错误,作为类的文档 java .sql.Date 状态

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


为了符合SQL DATE的定义,由java包装的毫秒值.sql.Date实例必须通过将实例关联的特定时区中的小时,分​​钟,秒和毫秒设置为零来实现。

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.

这篇关于ResultSet#getDate()语义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆