datetime conversion to JDBC

From: "Wendy L(dot) Fry" <fry(at)cmf(dot)nrl(dot)navy(dot)mil>
To: pgsql-sql(at)postgresql(dot)org
Cc: fry(at)cmf(dot)nrl(dot)navy(dot)mil
Subject: datetime conversion to JDBC
Date: 2000-03-06 20:23:53
Message-ID: 200003062025.PAA22714@ginger.cmf.nrl.navy.mil
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Browse pgsql-sql by date

  From Date Subject
Next Message Zot O'Connor 2000-03-07 04:47:21 change owner of database -- answer
Previous Message Ray Messier 2000-03-06 18:11:10 re: [SQL] Best method