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

From: Michael Stephenson <mstephenson(at)tirin(dot)openworld(dot)co(dot)uk>
To: PostgreSQL jdbc list <pgsql-jdbc(at)postgresql(dot)org>
Subject: getDate() and getTime() fails with columns of type 'TimeStamp'
Date: 2001-05-30 15:55:31
Message-ID: Pine.LNX.4.30.0105301636190.13426-100000@tirin.openworld.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc pgsql-patches


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);
}

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tony Grant 2001-05-30 16:20:29 Re: Fw: Druid problems
Previous Message Bruce Momjian 2001-05-30 13:04:12 Re: Fw: Druid problems

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2001-05-30 16:03:56 Re: Patch to remove sort files, temp tables, unreferenced files
Previous Message Tom Lane 2001-05-30 15:46:30 Re: Patch to remove sort files, temp tables, unreferenced files