Retrieve the server's time zone

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Retrieve the server's time zone
Date: 2017-11-21 07:01:39
Message-ID: ov0j0b$nmt$1@blaine.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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.

When I run "show timezone" from within JDBC I *always* get the client's time zone, even if I do a "reset timezone" before that

When I do the same with psql I can see the server's time zone.

Ultimately I would like to get the server's time, e.g. by running something like:

select current_timestamp at time zone server_timezone

I already posted this to the general mailing list, because I initially thought this was a Postgres problem.
Tom Lane suggested, I could see the original time zone the server is set up with using:

select reset_val from pg_settings where name = 'TimeZone';

But that again returns the client's time zone through JDBC, but the real time zone through psql.

It seems the driver changes this setting permanently for the session.
If that is the case, can I prevent that somehow?

Thomas

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2017-11-21 11:29:53 Re: Retrieve the server's time zone
Previous Message Michael Paquier 2017-11-21 04:36:08 Re: [JDBC] [HACKERS] Channel binding support for SCRAM-SHA-256