Mapping of timestamptz to TIMESTAMP vs. TIMESTAMP_WITH_TIMEZONE

From: Ben Horowitz <bhorowit(at)gmail(dot)com>
To: pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject: Mapping of timestamptz to TIMESTAMP vs. TIMESTAMP_WITH_TIMEZONE
Date: 2023-11-18 01:19:26
Message-ID: CAM1tkGVCRayeakBXb7ZqDTuJRFup7_kiF1S4gc8-_b99Cy0i-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

Apologies if this is a duplicate of an answered question. I searched in the
mailing list archives, Stack Overflow, etc., and didn't find anything.

At the line linked below in TypeInfoCache, it appears that type timestamptz
is getting mapped to the type java.sql.Types.TIMESTAMP [1] . It seems like
it should be mapped to java.sql.Types.TIMESTAMP_WITH_TIMEZONE.

TIMESTAMP_WITH_TIMEZONE was introduced in Java 8 (2014). Is the mapping of
timestamptz to TIMESTAMP intentional for reasons of backwards compatibility?

I found the behavior surprising, and also found a question on Stack
Overflow where someone else was surprised [2].

Thanks very much,
Ben

[1]
https://github.com/pgjdbc/pgjdbc/blob/65f158ed8e06ffea77ca7f3b8413847817a7831f/pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java#L106

[2]
https://stackoverflow.com/questions/60451102/for-postgresql-resultsetmetadata-getcolumntype-function-returns-same-value-ty

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2023-11-20 15:19:19 Re: Mapping of timestamptz to TIMESTAMP vs. TIMESTAMP_WITH_TIMEZONE
Previous Message Dave Cramer 2023-11-08 16:50:18 Re: Connection Timeout Issue due to intermittent non-response of Postgre database