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
pgsql-sql by date
|Next:||From: Zot O'Connor||Date: 2000-03-07 04:47:21|
|Subject: change owner of database -- answer|
|Previous:||From: Ray Messier||Date: 2000-03-06 18:11:10|
|Subject: re: [SQL] Best method|