From: | Boris Kirzner <borisk(at)mainsoft(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Bug in storing Timestamp |
Date: | 2005-04-11 12:39:56 |
Message-ID: | 425A701C.6070608@mainsoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Short description :
Storing java.sql.Timestamp with specified milliseconds value results to
wrong value stored in db.
System details :
OS : WindowsXP
PostgreSQL version : 8.0.1
Driver version : 8.0 build 310
Detailed description :
In order to reproduce the bug run the following code.
Create the table in the db.
The code creates a timestamp of "0001-01-01 02:02:02.0" and stores it
into the db.
The actual value stored is "02:22:42".
CREATE TABLE TYPES_EXTENDED (
id char(10),
t_time time
)
WITHOUT OIDS;
long milliseconds = Timestamp.valueOf("0001-01-01 02:02:02.0").getTime();
Timestamp javaTimestamp = new Timestamp(milliseconds);
System.out.println("Timestamp stored : " + javaTimestamp);
PreparedStatement stmt = connection.prepareStatement("insert into
types_extended(ID,t_time) values ('aaa',?)");
stmt.setTimestamp(1, javaTimestamp);
stmt.execute();
Thank you in advance,
--
Boris Kirzner
Mainsoft Corporation
http://www.mainsoft.com
From | Date | Subject | |
---|---|---|---|
Next Message | mikael-aronsson | 2005-04-11 14:57:57 | Re: Bug in storing Timestamp |
Previous Message | sandrigo.lezcano | 2005-04-11 12:06:05 | demo to use J2ME and Wireless Toolkit 2.2 |