JDBC Driver and timezones

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема JDBC Driver and timezones
Дата
Msg-id hstmm1$96v$1@dough.gmane.org
обсуждение исходный текст
Ответы Re: JDBC Driver and timezones  (Oliver Jowett <oliver@opencloud.com>)
Re: JDBC Driver and timezones  ("Carsten Klein" <carsten.klein@axn-software.de>)
Список pgsql-jdbc
Hi,

I have a little problem regarding timezones in the JDBC driver.

I have a locally installed Postgres server (PG 8.4.3 on Windows XP), so there is no difference between the timezone of
theserver and the client application. 

When I run the following in psql:

select current_time, localtime;

I get the following output:

      timetz      |     time
-----------------+--------------
  11:15:30.464+02 | 11:15:30.464
(1 row)

which is fine.

Now when I run the same statement through JDBC :

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select current_time, localtime");
if (rs.next())
{
   System.out.println("current_time: " + rs.getTime(1).toString());
   System.out.println("localtime: " + rs.getTime(2).toString());
}

I get the following output:

current_time: 10:18:49
localtime: 11:18:49

My expectation would have been to get the same display, but the current_time is one our off, which seems to be a
problemwith the daylight savings time.I 

The timezone for my computer is setup correctly (the clock is showing the correct time, and apparently psql has the
correcttime as well) 

The display from Java only works if I explicitely set the timezone when starting the JVM using -Duser.timezone=GMT+2

Is this a Java/JDK problem, a Windows problem or a driver problem?
I'm using JDK 1.6.0_18


Regards
Thomas

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: Connection fails when the user name contains chinese characters
Следующее
От: Rod
Дата:
Сообщение: After server restart I get - An I/O error occured while sending to the backend.