Re: JDBC Driver and timezones

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC Driver and timezones
Date: 2010-05-18 22:01:29
Message-ID: hsv2np$qhq$1@dough.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Carsten Klein wrote on 18.05.2010 23:35:

> actually, your application server is not using the system's default
> timezone, see the configuration of your server.

The timezone is correct. The DST information seems to be "broken".

Besides: I'm not using an application server. It's a Swing application that retrieves the data via JDBC

The output from my initial post was from a very simply main() class, only runs that single statement I posted in my initial post.
Even then it only works when I manually set user.timezone=GMT+2

And for the test case the client application _and_ Postgres were running on the same physical machine. So the JVM (and thus the JDBC driver) and Postgres should use the same timezone information from my Windows.

When I output the value of user.timezone (when not setting it manually) it does report the correct one: Europe/Berlin, but for some reason it does not apply the DST settings correctly.

> In order to overcome this problem, I have adjusted a db layer that we are
> using in the OSS VerA.Web project so that it will use proxies for the most
> relevant objects (resultset and so on) that then will just drop the
> timezone information in the data received from the database, so that when
> instantiating the datetime object in the application server, it will
> automatically take over the configured timezone. That way, you will
> experience no timeshift, whatsoever.
>
> See
> https://evolvis.org/scm/viewvc.php/tags/tarent-database-1.5.4verawebpl3/src/main/java/de/tarent/dblayer/engine/proxy/?root=tarentdatabase

Thanks for the link, but as I said: this is a Swing application that directly connects to the Postgres server.
But I'm curious: why didn't you simply change the timezone for the JVM running your appserver?

Regards
Thomas

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Matt Solnit 2010-05-18 23:49:03 Change the socket timeout of a live connection?
Previous Message harryh 2010-05-18 21:52:17 no timeout in AbstractJdbc23PoolingDataSource#getPooledConnection