Redshift jdbc driver getdate() returns time in server time zone instead of in UTC

0

The java code mentioned below was working fine with Redshift jdbc driver 1.2. But, now seeing erroneous behaviour with Redshift jdbc driver 2.1. Can anyone confirm whether a workaround is possible in this java code or whether this is a bug in the driver 2.1 itself?

Information about Java code

  • In a timestamp data-typed column, the value is inserted using "getdate()".
  • It is supposed to add time in UTC (without timezone information).
  • How the insert query is written:
connection.prepareStatement("INSERT INTO sampleTable (tsColumn, ...) VALUES (getdate(), ...)");

jdbc driver 1.2.41.1065 inserts correct date in UTC

jdbc driver 2.1.0.5 insertes date in PDT (server time zone) INCORRECT

Workaround attempted:

  • Attempted to modify getdate() part in the query as follows but it didn't work:
convert_timezone('UTC', getdate())

Questions

  • Is this a bug in the driver 2.1?
  • Is there any workaround/configuration/code-fix possible in the java code explained above?

Related

Hitesh
질문됨 2년 전609회 조회
1개 답변
1

Hi Hitesh,

We decided this behavior because JDBC respect JVM timezone. You can set session timezone if you like to change using JVM system property user.timezone value.

Thank you.

AWS
답변함 2년 전
  • Thank you @aws-msharma. Need to evaluate that option. And what about "convert_timezone('UTC', getdate())". Shouldn't it give time in UTC? Does the expression need any correction? Any other workaround?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠