You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Markus Reich <ma...@markusreich.at> on 2015/08/02 10:54:46 UTC

Re: Set timezone on connection

Hi,

here is an example

conn = ((DataContext)
context).getParentDataDomain().getDefaultNode().getDataSource().getConnection();
OracleConnection c = (OracleConnection) conn.getMetaData().getConnection();
TimeZone tz = TimeZone.getTimeZone("Europe/Berlin");
c.setDefaultTimeZone(TimeZone.getTimeZone("GMT+0" + tz.getOffset(new
Date().getTime()) / 1000 / 3600 + ":00"));

2015-07-31 19:25 GMT+02:00 Andrus Adamchik <an...@objectstyle.org>:

> > We found a possibility in setting a certain timezone on the java
> connection.
>
> Could you show an example of this?
>
>
> > On Jul 31, 2015, at 5:18 PM, Markus Reich <ma...@markusreich.at>
> wrote:
> >
> > Hi,
> >
> > we've some problems with oracle and timzone in combination with daylight
> > savings :-(
> > When I search the web to this topic, I can see that we are not the only
> one
> > having problems concerning oracle and daylight saving ;-)
> > But it seems that there's no proper solution to fix it :-(
> >
> > We found a possibility in setting a certain timezone on the java
> connection.
> > My question what would be the best solution in cayenne to set the
> timezone
> > on the based java connection object?
> >
> > br
> > Meex
>
>


-- 
*Markus Reich*
Waldweg 62
6393 St. Ulrich am Pillersee
www.markusreich.at / www.meeximum.at
markus.reich@markusreich.at

Re: Set timezone on connection

Posted by Michael Gentry <mg...@masslight.net>.
Hi Markus,

If I'm reading the JavaDocs correctly for OracleConnection, then it is
simply an extension of JDBC's Connection, which means you'd probably run
into issues when using a connection pool, as you are only setting the time
zone on one connection.  Also, many connection pools will close idle
connections, and I suspect any time zone information would be lost for that
connection as well.

mrg


On Sun, Aug 2, 2015 at 4:54 AM, Markus Reich <ma...@markusreich.at>
wrote:

> Hi,
>
> here is an example
>
> conn = ((DataContext)
>
> context).getParentDataDomain().getDefaultNode().getDataSource().getConnection();
> OracleConnection c = (OracleConnection) conn.getMetaData().getConnection();
> TimeZone tz = TimeZone.getTimeZone("Europe/Berlin");
> c.setDefaultTimeZone(TimeZone.getTimeZone("GMT+0" + tz.getOffset(new
> Date().getTime()) / 1000 / 3600 + ":00"));
>
> 2015-07-31 19:25 GMT+02:00 Andrus Adamchik <an...@objectstyle.org>:
>
> > > We found a possibility in setting a certain timezone on the java
> > connection.
> >
> > Could you show an example of this?
> >
> >
> > > On Jul 31, 2015, at 5:18 PM, Markus Reich <markus.reich@markusreich.at
> >
> > wrote:
> > >
> > > Hi,
> > >
> > > we've some problems with oracle and timzone in combination with
> daylight
> > > savings :-(
> > > When I search the web to this topic, I can see that we are not the only
> > one
> > > having problems concerning oracle and daylight saving ;-)
> > > But it seems that there's no proper solution to fix it :-(
> > >
> > > We found a possibility in setting a certain timezone on the java
> > connection.
> > > My question what would be the best solution in cayenne to set the
> > timezone
> > > on the based java connection object?
> > >
> > > br
> > > Meex
> >
> >
>
>
> --
> *Markus Reich*
> Waldweg 62
> 6393 St. Ulrich am Pillersee
> www.markusreich.at / www.meeximum.at
> markus.reich@markusreich.at
>