pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Wendy L. Fry <fry@cmf.nrl.navy.mil>
To: pgsql-sql@postgresql.org
Cc: fry@cmf.nrl.navy.mil
Subject: datetime conversion to JDBC
Date: Mon, 06 Mar 2000 15:23:53 -0500
Message-ID: <200003062025.PAA22714@ginger.cmf.nrl.navy.mil> (raw)

I have a PostgreSQL database that is acting sort of like a datebook.  One
of the tables in the database has a column for storing a begin date and a
column for an end date.  I've made the data type of these two columns
timestamp (I've tried datetime as well).

I'm writing Java code to perform queries on the database, for example:

Statement stmt = con.createStatement();
              
String command = "SELECT * FROM dates WHERE ((dates.fromDate >= '2000-2-1
00:00:00') AND (dates.toDate <= '2000-3-1 00:00:00'))";
ResultSet rs = stmt.executeQuery(command);

String name = rs.getString(1);
int activityID = rs.getInt(2);
Timestamp beginDate = rs.getTimestamp(3);
Timestamp endDate = rs.getTimestamp(4);

Getting the name and activityID work fine, but the next lines cause an
"SQLException: Bad abstime external representation ''"

I've tried to use types Date, String, and Object instead of Timestamp in
the java code and they all return the same error.

What is the correct way to get the column value in Java when the PostgreSQL
column type is timestamp?

I initially was representing dates in my database as integers (one integer
column for each: month, day, year, hour, minute, second) but that made
queries on the date extremely difficult to do.  Using a type such as
timestamp and datetime simplify the query greatly and I'd like to be able
to use them.

Thank you for any help anyone can offer.  I've been unable to find any
references to this problem in any of the mailing archives or PostgreSQL
documentation.

Sincerely,

Wendy Fry



Message-ID: <200003062025.PAA22714@ginger.cmf.nrl.navy.mil>
Permalink:  ../200003062025.PAA22714@ginger.cmf.nrl.navy.mil/
Also on:    postgresql.org/message-id/200003062025.PAA22714@ginger.cmf.nrl.navy.mil

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: fry@cmf.nrl.navy.mil
  Subject: Re: datetime conversion to JDBC
  In-Reply-To: <200003062025.PAA22714@ginger.cmf.nrl.navy.mil>
  References: <200003062025.PAA22714@ginger.cmf.nrl.navy.mil>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox