From: | Laurette Cisneros <laurette(at)nextbus(dot)com> |
---|---|
To: | Barry Lind <barry(at)xythos(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: jdbc problem with time |
Date: | 2002-07-10 17:27:02 |
Message-ID: | Pine.LNX.4.44.0207101026280.26912-100000@visor.corp.nextbus.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Great. Thanks.
P.S. We patched it here too...score one for open source.
However, we will test your too.
Thanks again,
Laurette
On Tue, 9 Jul 2002, Barry Lind wrote:
> Laurette,
>
> I have committed a fix for this bug. Please try the latest dev build on
> the website to see that it fixes your problem.
>
> thanks,
> --Barry
>
> Laurette Cisneros wrote:
>
> >Yes, the bug still exists in the latest development driver.
> >
> >Thanks,
> >
> >L.
> >On Tue, 9 Jul 2002, Barry Lind wrote:
> >
> >
> >
> >>Laurette,
> >>
> >>What version are you using? Can you still reproduce the problem with
> >>the latest development drivers (which you can download from
> >>jdbc.postgresql.org)?
> >>
> >>thanks,
> >>--Barry
> >>
> >>Laurette Cisneros wrote:
> >>
> >>
> >>
> >>>Any ideas on this?
> >>>
> >>>We have a table:
> >>>
> >>>xyzzy=# select sched_id, tod_start, tod_end from schedule where sched_id=1;
> >>>
> >>>sched_id | tod_start | tod_end
> >>>----------+-----------+---------------
> >>> 1 | 00:00:00 | 23:59:59.9990
> >>>
> >>>Notice the millisecond values set for tod_end. The jdbc driver barfs when
> >>>trying to read the time from the result set using the java code:
> >>>Time t = rs.getTime("tod_end");
> >>>
> >>>The stack trace from here looks like:
> >>>
> >>>java.lang.StringIndexOutOfBoundsException: String index out of range: 19
> >>>at java.lang.String.substring(String.java:1522) at
> >>>org.postgresql.jdbc2.ResultSet.toTime(ResultSet.java:1586) at
> >>>org.postgresql.jdbc2.ResultSet.getTime(ResultSet.java:385) at
> >>>org.postgresql.jdbc2.ResultSet.getTime(ResultSet.java:612) at
> >>>COM.NextBus.signad.SelectScheduleDetails.getObject(SelectScheduleDetails.java:30)
> >>>at
> >>>
> >>>Here is the offending piece of code. It fails in the case where the time
> >>>string looks like: "HH:MM:SS:mmmm". The code assumes that anything longer
> >>>than 8 characters is a timestamp and tries to get a substring accordingly.
> >>>However, the substring call fails, since this is a "time without time
> >>>zone" and not an SQL timestamp.
> >>>
> >>>Here is the code:
> >>>
> >>>public static Time toTime(String s) throws SQLException
> >>>{
> >>> if (s == null)
> >>> return null; // SQL NULL
> >>> // length == 8: SQL Time
> >>> // length > 8: SQL Timestamp
> >>> try
> >>> {
> >>> return java.sql.Time.valueOf((s.length() == 8) ? s : s.substring(11, 19));
> >>> }
> >>> catch (NumberFormatException e)
> >>> {
> >>> throw new PSQLException("postgresql.res.badtime", s);
> >>> }
> >>>}
> >>>
> >>>
> >>>Thanks for the help,
> >>>
> >>>---
> >>>Laurette Cisneros
> >>>The Database Group
> >>>(510) 420-3137
> >>>NextBus Information Systems, Inc.
> >>>www.nextbus.com
> >>>----------------------------------
> >>>"Intelligence complicates. Wisdom simplifies."
> >>> -- Mason Cooley
> >>>
> >>>
> >>>---------------------------(end of broadcast)---------------------------
> >>>TIP 2: you can get off all lists at once with the unregister command
> >>> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
> >
>
>
--
Laurette Cisneros
The Database Group
(510) 420-3137
NextBus Information Systems, Inc.
www.nextbus.com
----------------------------------
"Intelligence complicates. Wisdom simplifies."
-- Mason Cooley
From | Date | Subject | |
---|---|---|---|
Next Message | Chris White | 2002-07-10 23:49:39 | Getting oid of 0 when doing LargeObjectManager.create() |
Previous Message | tony | 2002-07-10 12:31:00 | Re: Connect using md5 |