Re: Retrieve the server's time zone

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Retrieve the server's time zone
Date: 2017-11-21 14:57:49
Message-ID: CAKFQuwbPDsRjd09-J3_Me0R8__NJKD5Mu20zdu=SniDONF734w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Tue, Nov 21, 2017 at 12:01 AM, Thomas Kellerer <spam_eater(at)gmx(dot)net>
wrote:

> Hello,
>
> it seems the JDBC driver (or Java?) makes it impossible to retrieve the
> server's time zone.
>
> Apparently the driver changes the timezone setting so that it can't be
> reset to the original from the server.
>

​Yes, this is the case. No, in the current code there is no means to
prevent it.

https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/core/v3/ConnectionFactoryImpl.java#L198

psql doesn't provide object instantiation on the results being passed back
from the server: all it does is print stuff to the screen. That JDBC and
psql different in their behavior with respect to timestamps/dates is
unsurprising in that light. I don't know how libpq-based C (or other)
language programs operate within this area but that would be the proper API
to compare JDBC to.

As a work-around have your application require psql on the client machine
and shell out to it. Or hack the driver - though using your timezone-less
connection for anything other than finding out the server timezone is
probably something you'd want to avoid.

David J.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message rob stone 2017-11-21 16:51:03 Re: Retrieve the server's time zone
Previous Message Vladimir Sitnikov 2017-11-21 14:29:52 Re: Retrieve the server's time zone