Bug in storing Timestamp

Поиск
Список
Период
Сортировка
От Boris Kirzner
Тема Bug in storing Timestamp
Дата
Msg-id 425A701C.6070608@mainsoft.com
обсуждение исходный текст
Ответы Re: Bug in storing Timestamp  (Kris Jurka <books@ejurka.com>)
Список 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


В списке pgsql-jdbc по дате отправления:

Предыдущее
От:
Дата:
Сообщение: demo to use J2ME and Wireless Toolkit 2.2
Следующее
От: "mikael-aronsson"
Дата:
Сообщение: Re: Bug in storing Timestamp