PostgreSQL 9.2 JDBC driver uses client time zone?

前端 未结 5 1631
遥遥无期
遥遥无期 2020-12-09 09:38

I\'ve run into an interesting challenge using a PostgreSQL database with the PostgreSQL JDBC driver. It seems that the latest version of the driver, 9.2, uses the client

5条回答
  •  星月不相逢
    2020-12-09 10:18

    I just ran into this issue myself. I verified that the postgres jdbc driver is indeed picking up the connection timezone from the jvm, and I wasn't able to find a way to override this behavior. It really would be nice if they provided a jdbc url connection parameter for this purpose.

    As a workaround, I discovered that my connection pool library (HikariCP) can execute a sql statement for each new connection:

    hikariConfig.setConnectionInitSql("set time zone 'UTC'");
    

提交回复
热议问题