Thread: Bad Timestamp Format Error
Hi all, I'm writing a Java program that uses JDBC to extract data from existing databases, one of which is PostgreSQL. When it tries to read a timestamp created using NOW() from the postgreSQL database, it throws an exception. If I enter the time manually such that there are no nanoseconds it works fine. So if I set datebegin using NOW(), it looks something like: 2002-07-31 09:18:01.414573-07 and when I use this Java statement: campaign.setStart( sqlResults.getTimestamp(4).getTime() ); where campaign.setStart looks like: public void setStart(long useDate) { begin = new Date(useDate); } I get the exception: Bad Timestamp Format at 23 in 2002-07-31 09:18:01.414573-07 However, if I set datebegin as: 2002-07-31 09:18:01-07 it works fine.... Any ideas on how to get around this??? The database used NOW() for timestamps throughout, so nanoseconds are everywhere. thanks in advance, Paul
BOY DO I FEEL DUMB!! Sorry everyone.... I had the jdbc7.1-1.2.jar on my dev machine, and the production machine had pgjdbc2.jar running a 7.2.1 PostgreSQL database..... When I updated my dev machine's jar to pgjdbc2.jar (actually I got devpgjdbc2.jar) everything was fine.... Just shows to go ya!!! Know what versions of EVERYTHING you are running EVERYWHERE!! (red-faced) Paul -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Paul Stead Sent: Wednesday, July 31, 2002 12:05 PM To: pgsql-jdbc@postgresql.org Subject: [JDBC] Bad Timestamp Format Error Hi all, I'm writing a Java program that uses JDBC to extract data from existing databases, one of which is PostgreSQL. When it tries to read a timestamp created using NOW() from the postgreSQL database, it throws an exception. If I enter the time manually such that there are no nanoseconds it works fine. So if I set datebegin using NOW(), it looks something like: 2002-07-31 09:18:01.414573-07 and when I use this Java statement: campaign.setStart( sqlResults.getTimestamp(4).getTime() ); where campaign.setStart looks like: public void setStart(long useDate) { begin = new Date(useDate); } I get the exception: Bad Timestamp Format at 23 in 2002-07-31 09:18:01.414573-07 However, if I set datebegin as: 2002-07-31 09:18:01-07 it works fine.... Any ideas on how to get around this??? The database used NOW() for timestamps throughout, so nanoseconds are everywhere. thanks in advance, Paul ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
BOY DO I FEEL DUMB!! Sorry everyone.... I had the jdbc7.1-1.2.jar on my dev machine, and the production machine had pgjdbc2.jar running a 7.2.1 PostgreSQL database..... When I updated my dev machine's jar to pgjdbc2.jar (actually I got devpgjdbc2.jar) everything was fine.... Just shows to go ya!!! Know what versions of EVERYTHING you are running EVERYWHERE!! (red-faced) Paul -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Paul Stead Sent: Wednesday, July 31, 2002 12:05 PM To: pgsql-jdbc@postgresql.org Subject: [JDBC] Bad Timestamp Format Error Hi all, I'm writing a Java program that uses JDBC to extract data from existing databases, one of which is PostgreSQL. When it tries to read a timestamp created using NOW() from the postgreSQL database, it throws an exception. If I enter the time manually such that there are no nanoseconds it works fine. So if I set datebegin using NOW(), it looks something like: 2002-07-31 09:18:01.414573-07 and when I use this Java statement: campaign.setStart( sqlResults.getTimestamp(4).getTime() ); where campaign.setStart looks like: public void setStart(long useDate) { begin = new Date(useDate); } I get the exception: Bad Timestamp Format at 23 in 2002-07-31 09:18:01.414573-07 However, if I set datebegin as: 2002-07-31 09:18:01-07 it works fine.... Any ideas on how to get around this??? The database used NOW() for timestamps throughout, so nanoseconds are everywhere. thanks in advance, Paul ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org