Skip site navigation (1) Skip section navigation (2)

Fwd: Bug in getTimestamp() of PostgreSQL JDBC driver?

From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Fwd: Bug in getTimestamp() of PostgreSQL JDBC driver?
Date: 2002-03-09 11:50:08
Message-ID: 5.1.0.14.0.20020309114957.00aa24c0@mail.retep.org.uk (view raw or flat)
Thread:
Lists: pgsql-bugs
>X-Sieve: cmu-sieve 2.0
>From: "Alex Cholokov" <al_chaldon(at)nvkz(dot)net>
>To: <peter(at)retep(dot)org(dot)uk>
>Subject: Bug in getTimestamp() of PostgreSQL JDBC driver?
>Date: Wed, 6 Mar 2002 15:48:20 +0700
>X-Mailer: Microsoft Outlook, Build 10.0.2627
>Importance: Normal
>
>Hello Peter,
>
>I have problem with JDBC driver for PostgreSQL
>When i call getTimeStamp() method of ResultSet it gave me :
>======================================================================
>[14:38:15,755,Default] java.lang.StringIndexOutOfBoundsException: String 
>index out of range: 23
>[14:38:15,755,Default]  at java.lang.String.charAt(String.java:507)
>[14:38:15,765,Default]
>[14:38:15,765,Default]  at 
>org.postgresql.jdbc2.ResultSet.toTimestamp(ResultSet.java:1656)
>[14:38:15,765,Default]
>[14:38:15,765,Default]  at 
>org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java:398)
>[14:38:15,765,Default]
>[14:38:15,765,Default]  at 
>org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java:617)
>[14:38:15,765,Default]
>[14:38:15,765,Default]  at 
>org.jboss.pool.jdbc.ResultSetInPool.getTimestamp(Unknown Source)
>[14:38:15,765,Default]
>[14:38:15,765,Default]  at org.peoplink.ejb.SyncEJB.getkeys(SyncEJB.java:902)
>[14:38:15,765,Default]
>[14:38:15,765,Default]  at org.peoplink.ejb.SyncEJB.invoke(SyncEJB.java:150)
>[14:38:15,765,Default]
>[14:38:15,765,Default]  at java.lang.reflect.Method.invoke(Native Method)
>[14:38:15,775,Default]
>[14:38:15,775,Default]  at 
>org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(StatefulSessionContainer.java:664)
>[14:38:15,775,Default]
>[14:38:15,775,Default]  at 
>org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
>[14:38:15,775,Default]
>[14:38:15,775,Default]  at 
>org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:299)
>[14:38:15,775,Default]
>[14:38:15,775,Default]  at 
>org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:242)
>[14:38:15,775,Default]
>[14:38:15,775,Default]  at 
>org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
>[14:38:15,775,Default]
>[14:38:15,775,Default]  at 
>org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContainer.java:339)
>[14:38:15,775,Default]
>[14:38:15,775,Default]  at 
>org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:410)
>[14:38:15,785,Default]
>[14:38:15,785,Default]  at 
>org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:491)
>[14:38:15,785,Default]
>[14:38:15,785,Default]  at 
>org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335)
>[14:38:15,785,Default]
>[14:38:15,785,Default]  at 
>org.jboss.ejb.plugins.jrmp.interfaces.StatefulSessionProxy.invoke(StatefulSessionProxy.java:136)
>...
>etc...
>======================================================================
>i checked the date returned from backend it is '2002-03-06 
>06:48:01.912'  with total length 23.
>So i had modified rows of org.postgresql.jdbc2.ResultSet.java (below row 
>1644) from:
>======================================================================
>     char c = s.charAt(i++);
>     if (c == '.')
>     {
>      // Found a fractional value. Append up to 3 digits including
>      // the leading '.'
>      do
>      {
>       if (i < 24)
>        resultSet.sbuf.append(c);
>       c = s.charAt(i++);
>      } while (Character.isDigit(c));
>
>      // If there wasn't at least 3 digits we should add some zeros
>      // to make up the 3 digits we tell java to expect.
>      for (int j = i; j < 24; j++)
>       resultSet.sbuf.append('0');
>     }
>======================================================================
>to
>======================================================================
>     int slen = s.length();
>     char c = s.charAt(i++);
>     if (c == '.')
>     {
>      slen = ( slen < 23)? slen: 23;
>      // Found a fractional value. Append up to 3 digits including
>      // the leading '.'
>      do
>      {
>       resultSet.sbuf.append(c);
>       if( i < slen)
>        c = s.charAt(i++);
>       else
>        break;
>      } while (Character.isDigit(c));
>
>      // If there wasn't at least 3 digits we should add some zeros
>      // to make up the 3 digits we tell java to expect.
>      for (int j = i; j < 23; j++)
>       resultSet.sbuf.append('0');
>     }
>======================================================================
>and problem disappeared.
>
>I had used jdbc driver from postgresql-7.2.tar.gz and precompiled driver 
>from jdbc.postgresql.org  - the same problem.
>
>Best regards,
>Alexey.
>
>Page via e-mail (400 chars max): 
><mailto:10304(at)alel(dot)rdtc(dot)ru>10304@<mailto:10304(at)alel(dot)rdtc(dot)ru>alel.rdtc.ru
>Additional e-mail: 
><mailto:al_chaldon(at)nvkz(dot)kuzbass(dot)net>al_chaldon(at)nvkz(dot)kuzbass(dot)net
>MSN Messenger id: <mailto:al_chaldon(at)hotmail(dot)com>al_chaldon(at)hotmail(dot)com
>Yahoo Messenger id: alexey_cholokov
>ICQ: 7898280
>Phone: 7(3843)786085
>
>



pgsql-bugs by date

Next:From: Bhuvan ADate: 2002-03-11 05:14:28
Subject: comparing null value in plpgsql.
Previous:From: Juliano IgnacioDate: 2002-03-08 17:44:40
Subject: Re: Bug #608: cache lookup failed

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group