Re: getDate() and getTime() fails with columns of type 'TimeStamp'

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Michael Stephenson <mstephenson(at)tirin(dot)openworld(dot)co(dot)uk>
Cc: PostgreSQL jdbc list <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: getDate() and getTime() fails with columns of type 'TimeStamp'
Date: 2001-05-30 16:35:41
Message-ID: 200105301635.f4UGZfo08370@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc pgsql-patches


I just applied this patch sent in by someone else to the current CVS
tree.

>
> In org.postgresql.jdbc2.ResultSet, both getDate() and getTime() fail on
> columns of type 'timestamp', which is against the jdbc spec, patch below
> fixes it.
>
> Michael Stephenson mstephenson(at)openworld(dot)co(dot)uk
> Developer - Web Applications - Open World
> Tel: +44 1225 444 950 Fax: +44 1225 336 738
>
>
>
> --- ResultSet.java.old Wed May 30 16:32:48 2001
> +++ ResultSet.java Wed May 30 16:41:33 2001
> @@ -423,6 +423,8 @@
> String s = getString(columnIndex);
> if(s==null)
> return null;
> + if (s.length() > 10)
> + return new java.sql.Date(getTimeStamp(columnIndex).getTime())
>
> return java.sql.Date.valueOf(s);
> }
> @@ -441,6 +443,8 @@
>
> if(s==null)
> return null; // SQL NULL
> + if (s.length() > 8)
> + return new java.sql.Time(getTimeStamp(columnIndex).getTime());
>
> return java.sql.Time.valueOf(s);
> }
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Attachment Content-Type Size
unknown_filename text/plain 1007 bytes

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Larry Mulcahy 2001-05-30 17:22:48 "No class found for inet"
Previous Message Bruce Momjian 2001-05-30 16:34:53 Re: [JDBC] Re: Trouble with JDBC2 ResultSet.getDate()

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2001-05-30 16:53:50 Re: Re: [GENERAL] Patch for PGACCESS
Previous Message Tom Lane 2001-05-30 16:30:23 Re: Support for %TYPE in CREATE FUNCTION