Re: SQL solution for my JDBC timezone issue

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: George Woodring <george(dot)woodring(at)iglass(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL solution for my JDBC timezone issue
Date: 2015-02-23 15:45:33
Message-ID: CADK3HHLbBxNM8B7DLGGL8vxYYZPiyAxy1aLsCFbj=dH6_so_KQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Timestamps have always been a bit of a pain since JDBC does not support
both with and without timezones. It really only supports timestamps with
timezone.

We have made decisions in the driver which are not optimal for everyone.
The reason it does this is for binary transfers of data. We need to control
which timezone both the server and the client are operating in.

I'm open to suggestions ?

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On 23 February 2015 at 10:42, George Woodring <george(dot)woodring(at)iglass(dot)net>
wrote:

> Yes, that is where we think we are heading, the issue is that the code
> does not know what it needs to be set back to. We have 90 databases with 5
> different time zones. I was just hoping for a more elegant solution than
> writing a lookup table that says if you are connecting to db x then set to
> timezone y.
>
> George Woodring
>
> iGLASS Networks
> www.iglass.net
>
> On Mon, Feb 23, 2015 at 9:16 AM, Dave Cramer <pg(at)fastcrypt(dot)com> wrote:
>
>> Well you could always just put it back to whatever you want when you open
>> the connection ie "set timezone ...."
>>
>>
>>
>> Dave Cramer
>>
>> dave.cramer(at)credativ(dot)ca
>> http://www.credativ.ca
>>
>> On 23 February 2015 at 08:40, George Woodring <george(dot)woodring(at)iglass(dot)net
>> > wrote:
>>
>>> Anyone have a suggestion for setting the timezone back to the Postgres
>>> db default on a connection. JDBC now sets the timezone to be the client
>>> which is my web server and ignores the default timezone that I have set in
>>> the DB. There are large parts of my code that I have never worried about
>>> timezones because the DB would handle it. Before I head down that path, I
>>> thought I would check and see if there was an easier way for me to put it
>>> back into the database.
>>>
>>> My latest issue is I create a date object and set it to 3am PST, If I
>>> save it into a timestamp with timezone the db saves it at 3am PST when I
>>> pull it out. If I save it to timestamp without timezone, I get 6am now
>>> where as before I would get 3am.
>>>
>>> Any suggestions would be appreciated
>>> George Woodring
>>> iGLASS Networks
>>> www.iglass.net
>>>
>>
>>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2015-02-23 15:47:55 Re: express composite type literal as text
Previous Message George Woodring 2015-02-23 15:42:17 Re: SQL solution for my JDBC timezone issue

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2015-02-23 15:49:53 Re: SQL solution for my JDBC timezone issue
Previous Message George Woodring 2015-02-23 15:42:17 Re: SQL solution for my JDBC timezone issue