X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C7F4A566B1 for ; Fri, 11 Mar 2005 14:56:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55858-08 for ; Fri, 11 Mar 2005 14:56:47 +0000 (GMT) Received: from ibixmailb.ibi.com (relayb.ibi.com [64.74.32.55]) by svr1.postgresql.org (Postfix) with SMTP id 4E35956601 for ; Fri, 11 Mar 2005 14:56:46 +0000 (GMT) Received: From ibiexchb.ibi.com ([172.18.1.43]) by ibixmailb.ibi.com (WebShield SMTP v4.5 MR1a); id 1110552913921; Fri, 11 Mar 2005 09:55:13 -0500 Received: from iwaysoftware.com (pgmsdl2.ibi.com [172.30.242.66]) by ibiexchb.ibi.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id G4S8K3SP; Fri, 11 Mar 2005 09:56:39 -0500 Message-ID: <4231B1A3.4050304@iwaysoftware.com> Date: Fri, 11 Mar 2005 09:56:35 -0500 From: Sergio Lob Reply-To: Sergio_Lob@iwaysoftware.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: oliver@opencloud.com Cc: pgsql-jdbc@postgresql.org, Ephraim_Spravtsev@iwaysoftware.com, "Lob, Sergio" Subject: Re: [BUGS] BUG #1523: precision column value returned from References: <422F6641.6030806@opencloud.com> In-Reply-To: <422F6641.6030806@opencloud.com> Content-Type: multipart/alternative; boundary="------------000007000500060107040400" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.414 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, HTML_20_30, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: X-Archive-Number: 200503/115 X-Sequence-Number: 12507 This is a multi-part message in MIME format. --------------000007000500060107040400 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I'll quote you what Oracle docs for their support of TIMESTAMP w/ time zone.... "TIMESTAMP WITH TIME ZONE Data Type By default, the Oracle TIMESTAMP WITH TIME ZONE data type is mapped to the VARCHAR JDBC data type. When retrieving TIMESTAMP WITH TIME ZONE values as a string (using resultSet.getString, for example), the value is returned as the string representation of the timestamp including time zone information. The string representation is formatted in the format specified by the Oracle NLS_TIMESTAMP_TZ_FORMAT session parameter. By default, retrieving TIMESTAMP WITH TIME ZONE values as a timestamp (using resultSet.getTimeStamp, for example) is not supported because the time zone information stored in the database would be lost when the data is converted to a timestamp. To provide backward compatibility with existing applications, you can use the FetchTSWTZasTimestamp property to allow TIMESTAMP WITH TIME ZONE values to be retrieved as a timestamp. The default value of the FetchTSWTSasTimestamp property is false, which disables retrieving TIMESTAMP WITH TIME ZONE values as timestamps." Oracle recognizes that the JDBC timestamp data type does not allow for timezones, thus they would map PostgresSQL timestamptz type to JDBC type varchar, not timestamp. PostgreSQL currently maps timestamptz to JDBC timestamp in DatabaseMetadata.getTypeInfo() method and in ResultSetMetaData.getColumnType() method. I tend to agree with their interpretation. Regards, Sergio oliver@opencloud.com wrote: >Sergio Lob wrote: > > > >>What format does PostgreSQL return in getString() method for a timestamp column, for example? Seems like it should return same as toString() method of a timestamp object as defined in java 2 api spec. >> >> > >It returns the string representation the backend gave it. This is true >for all types at the moment. For a timestamp with timezone value this is >generally going to be yyyy-mm-dd hh:mm:ss.nnnnnnzzz: > >test=# select now(); > now >------------------------------- > 2005-03-10 10:08:11.707753+13 >(1 row) > >Does the JDBC spec say somewhere that we should return a different format? > >-O > > --------------000007000500060107040400 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit I'll quote you what Oracle docs for their support of TIMESTAMP w/ time zone....

"TIMESTAMP WITH TIME ZONE Data Type

By default, the Oracle TIMESTAMP WITH TIME ZONE data type is mapped to the VARCHAR JDBC data type.

When retrieving TIMESTAMP WITH TIME ZONE values as a string (using resultSet.getString, for example), the value is returned as the string representation of the timestamp including time zone information. The string representation is formatted in the format specified by the Oracle NLS_TIMESTAMP_TZ_FORMAT session parameter.

By default, retrieving TIMESTAMP WITH TIME ZONE values as a timestamp (using resultSet.getTimeStamp, for example) is not supported because the time zone information stored in the database would be lost when the data is converted to a timestamp. To provide backward compatibility with existing applications, you can use the FetchTSWTZasTimestamp property to allow TIMESTAMP WITH TIME ZONE values to be retrieved as a timestamp. The default value of the FetchTSWTSasTimestamp property is false, which disables retrieving TIMESTAMP WITH TIME ZONE values as timestamps."

Oracle recognizes that the JDBC timestamp data type does not allow for timezones, thus they would map PostgresSQL timestamptz type to JDBC type varchar, not timestamp. PostgreSQL currently maps timestamptz to JDBC timestamp in DatabaseMetadata.getTypeInfo() method and in ResultSetMetaData.getColumnType() method. I tend to agree with their interpretation.

Regards, Sergio


oliver@opencloud.com wrote:
Sergio Lob wrote:

  
What format does PostgreSQL return in getString() method for a timestamp column, for example? Seems like it should return same as toString() method of a timestamp object as defined in java 2 api spec.
    

It returns the string representation the backend gave it. This is true 
for all types at the moment. For a timestamp with timezone value this is 
generally going to be yyyy-mm-dd hh:mm:ss.nnnnnnzzz:

test=# select now();
               now
-------------------------------
  2005-03-10 10:08:11.707753+13
(1 row)

Does the JDBC spec say somewhere that we should return a different format?

-O
  
--------------000007000500060107040400--