Bug #4978 | can not read field if TIME field's value=='838:59:59' | ||
---|---|---|---|
Submitted: | 10 Aug 2004 16:01 | Modified: | 10 Aug 2004 23:51 |
Reporter: | Serge Grachov | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / J | Severity: | S1 (Critical) |
Version: | 3.1.3 beta $Id: ResultSet.java,v 1.18.4. | OS: | Windows (w2k) |
Assigned to: | Mark Matthews | CPU Architecture: | Any |
[10 Aug 2004 16:01]
Serge Grachov
[10 Aug 2004 23:51]
Mark Matthews
The timespan can't possibly be represented correctly by a java.sql.Time (or any other datetime type in Java). If you try, you get a silent change to the value '05:57:11', which in my opinion is even worse than throwing the SQLException. Are you trying to represent a timespan with this value? If so, you'll need to write a custom class to handle it. JDBC provides no direct support for such a type, unfortunately.
[11 Aug 2004 0:22]
Serge Grachov
what about returning null+SQLWarning about precision lost there?
[28 Mar 2006 18:29]
Florian Rissner
java.sql.Time is a wrapped java.util.Date so it should be possible to represent this value with java.sql.Time it's even possible to represent negative time-Values (e.g. -04:00:00) as far as i see, there's only a slight change needed: if you get the Result-String (eg. -2006-03-28 04:12:13.0123) check wheter the first character is a minus-Sign; if so, set a factor = -1 and strip it from String (e.g. factor = -1; string = 2006-03-28 04:12:13.0123) then multiply every time-field with this factor as far as i see, there are no further problems. though i haven't tested yet. at lesat it would represent every possible mysql-time-value
[28 Mar 2006 18:49]
Mark Matthews
It might work okay _now_, but that's not how TIME is specified in the SQL standard or how the mapping to java.sql.Time is specified in the JDBC specification. According to both of these standards, "Time" represents time-of-day. If you want support for intervals (as specified in the SQL standard) then you should probably file a bug at http://java.sun.com/ against the JDBC spec itself, as this is not addressed currently, and doing what you suggest violates comaptibility with the specification, unfortunately.