Thread: Exception retrieving timestamp without timezone value

Exception retrieving timestamp without timezone value

From
Stephen Bacon
Date:
Hello,
  I've noticed an exception when dealing with a TIMESTAMP WITHOUT
TIMEZONE column.

my code (in an attempt to track it down) is:

  debugMessage("06");
  debugMessage(rsIRFPAIRec.getString("CreatedOn"));
  java.sql.Timestamp tsloadtemp = rsIRFPAIRec.getTimestamp("CreatedOn");
  debugMessage(tsloadtemp.toString());
  long lloadtemp = tsloadtemp.getTime();
  debugMessage(Long.toString(lloadtemp));
  java.util.Date dtloadtemp = new java.util.Date(lloadtemp);
  debugMessage(dtloadtemp.toString());

the output in my debug file is:

  *** Aug 15, 2002 2:34:49 PM 2001-12-03 14:28:53.77
  *** Aug 15, 2002 2:34:49 PM Exception loading from tblIRFPAI_Main:
  String index out of range: 22

So it seems that either the ResultSet.getTimestamp() is causing it, or
the Timestamp.toString() is.

Either way this seems to be a prob in the driver? I searched the archive
for this error, but only found it mentioned as fixed in regards to the
regular TIMESTAMP (i.e. with time zone)

Or maybe the pgjdbc2.jar file at
http://jdbc.postgresql.org/download.html is out of date?

further details:
                           version
-------------------------------------------------------------
 PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.96

"java -version" returns:
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

thanks,
  -Steve

p.s. this of course begs the question "why is he using WITHOUT TIMEZONE"
and the answer: no good reason! I've switched back to TIMESTAMP WITH
TIMEZONE and the problem disappears.



Re: Exception retrieving timestamp without timezone value

From
Barry Lind
Date:
Stephen,

This is fixed in current sources.  If you try the development build of
the driver off of the web site you should see this problem solved.

--Barry

Stephen Bacon wrote:

>Hello,
>  I've noticed an exception when dealing with a TIMESTAMP WITHOUT
>TIMEZONE column.
>
>my code (in an attempt to track it down) is:
>
>  debugMessage("06");
>  debugMessage(rsIRFPAIRec.getString("CreatedOn"));
>  java.sql.Timestamp tsloadtemp = rsIRFPAIRec.getTimestamp("CreatedOn");
>  debugMessage(tsloadtemp.toString());
>  long lloadtemp = tsloadtemp.getTime();
>  debugMessage(Long.toString(lloadtemp));
>  java.util.Date dtloadtemp = new java.util.Date(lloadtemp);
>  debugMessage(dtloadtemp.toString());
>
>the output in my debug file is:
>
>  *** Aug 15, 2002 2:34:49 PM 2001-12-03 14:28:53.77
>  *** Aug 15, 2002 2:34:49 PM Exception loading from tblIRFPAI_Main:
>  String index out of range: 22
>
>So it seems that either the ResultSet.getTimestamp() is causing it, or
>the Timestamp.toString() is.
>
>Either way this seems to be a prob in the driver? I searched the archive
>for this error, but only found it mentioned as fixed in regards to the
>regular TIMESTAMP (i.e. with time zone)
>
>Or maybe the pgjdbc2.jar file at
>http://jdbc.postgresql.org/download.html is out of date?
>
>further details:
>                           version
>-------------------------------------------------------------
> PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.96
>
>"java -version" returns:
>java version "1.4.0_01"
>Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
>Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
>
>thanks,
>  -Steve
>
>p.s. this of course begs the question "why is he using WITHOUT TIMEZONE"
>and the answer: no good reason! I've switched back to TIMESTAMP WITH
>TIMEZONE and the problem disappears.
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org
>
>
>