Thread: ResultSet.getDate failure with timestamp column

ResultSet.getDate failure with timestamp column

From
"Daniel Germain"
Date:
Hi,

I'm trying to migrate an existing application to postgresql
that uses generated code for accessing the database layer.

I search the mailing list and found other references to that problem
which seems to have been fixed in Revision 1.26 of ResultSet.java
and seems to be removed in Revision 1.29

Here is the stack trace with the DevelopmentDriver 7.2dev (built 2001-10-31)

java.lang.NumberFormatException: 04 00:00:00-04
    at java.lang.Integer.parseInt(Integer.java:414)
    at java.lang.Integer.parseInt(Integer.java:454)
    at java.sql.Date.valueOf(Date.java:91)
    at org.postgresql.jdbc2.ResultSet.toDate(ResultSet.java:1557)
    at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:372)
    at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:607)


Any good reason why it was removed? It seems to be contrary to the
spec from what I read in this mailing list.

Thanks

Daniel



Re: ResultSet.getDate failure with timestamp column

From
Barry Lind
Date:
Daniel,

You are correct.  Version 1.29 backed out the previous fix.  I will fix
this when I get a chance (unless you want to submit a patch and save me
some time?).

thanks,
--Barry

Daniel Germain wrote:

> Hi,
>
> I'm trying to migrate an existing application to postgresql
> that uses generated code for accessing the database layer.
>
> I search the mailing list and found other references to that problem
> which seems to have been fixed in Revision 1.26 of ResultSet.java
> and seems to be removed in Revision 1.29
>
> Here is the stack trace with the DevelopmentDriver 7.2dev (built 2001-10-31)
>
> java.lang.NumberFormatException: 04 00:00:00-04
>     at java.lang.Integer.parseInt(Integer.java:414)
>     at java.lang.Integer.parseInt(Integer.java:454)
>     at java.sql.Date.valueOf(Date.java:91)
>     at org.postgresql.jdbc2.ResultSet.toDate(ResultSet.java:1557)
>     at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:372)
>     at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:607)
>
>
> Any good reason why it was removed? It seems to be contrary to the
> spec from what I read in this mailing list.
>
> Thanks
>
> Daniel
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>



Re: ResultSet.getDate failure with timestamp column

From
Barry Lind
Date:
This bug has been fixed.

thanks,
--Barry

PS.  I didn't use the diff below since I also noticed that two other
changes were also backed out in 1.29.  So this fix fixes all three.



Daniel Germain wrote:

> Hi,
>
> diff -c "c:/postgresql/ResultSet.java.orig" "c:/postgresql/ResultSet.java"
> *** c:/postgresql/ResultSet.java.orig    Wed Nov 07 14:37:52 2001
> --- c:/postgresql/ResultSet.java    Fri Nov 09 08:46:30 2001
> ***************
> *** 1554,1560 ****
>       {
>           if (s == null)
>               return null;
> !         return java.sql.Date.valueOf(s);
>       }
>
>       public static Time toTime(String s) throws SQLException
> --- 1554,1566 ----
>       {
>           if (s == null)
>               return null;
> !         // length == 10: SQL Date
> !         // length >  10: SQL Timestamp, assumes PGDATESTYLE=ISO
> !         try {
> !            return java.sql.Date.valueOf((s.length() == 10) ? s :
> s.substring(0,10));
> !         } catch (NumberFormatException e) {
> !            throw new PSQLException("postgresql.res.baddate", s);
> !         }
>       }
>
>       public static Time toTime(String s) throws SQLException
>
> Diff finished at Fri Nov 09 08:47:03
>
> Daniel
>
>
>>-----Original Message-----
>>From: Barry Lind [mailto:barry@xythos.com]
>>Sent: November 8, 2001 10:50 PM
>>To: Daniel Germain
>>Cc: pgsql-jdbc@postgresql.org
>>Subject: Re: ResultSet.getDate failure with timestamp column
>>
>>
>>Daniel,
>>
>>You are correct.  Version 1.29 backed out the previous fix.  I will fix
>>this when I get a chance (unless you want to submit a patch and save me
>>some time?).
>>
>>thanks,
>>--Barry
>>
>>Daniel Germain wrote:
>>
>>
>>>Hi,
>>>
>>>I'm trying to migrate an existing application to postgresql
>>>that uses generated code for accessing the database layer.
>>>
>>>I search the mailing list and found other references to that problem
>>>which seems to have been fixed in Revision 1.26 of ResultSet.java
>>>and seems to be removed in Revision 1.29
>>>
>>>Here is the stack trace with the DevelopmentDriver 7.2dev
>>>
>>(built 2001-10-31)
>>
>>>java.lang.NumberFormatException: 04 00:00:00-04
>>>    at java.lang.Integer.parseInt(Integer.java:414)
>>>    at java.lang.Integer.parseInt(Integer.java:454)
>>>    at java.sql.Date.valueOf(Date.java:91)
>>>    at org.postgresql.jdbc2.ResultSet.toDate(ResultSet.java:1557)
>>>    at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:372)
>>>    at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:607)
>>>
>>>
>>>Any good reason why it was removed? It seems to be contrary to the
>>>spec from what I read in this mailing list.
>>>
>>>Thanks
>>>
>>>Daniel
>>>
>>>
>>>
>>>---------------------------(end of broadcast)---------------------------
>>>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>>>
>>>
>>>
>>
>
>



Re: ResultSet.getDate failure with timestamp column

From
"Daniel Germain"
Date:
Hi,

diff -c "c:/postgresql/ResultSet.java.orig" "c:/postgresql/ResultSet.java"
*** c:/postgresql/ResultSet.java.orig    Wed Nov 07 14:37:52 2001
--- c:/postgresql/ResultSet.java    Fri Nov 09 08:46:30 2001
***************
*** 1554,1560 ****
      {
          if (s == null)
              return null;
!         return java.sql.Date.valueOf(s);
      }

      public static Time toTime(String s) throws SQLException
--- 1554,1566 ----
      {
          if (s == null)
              return null;
!         // length == 10: SQL Date
!         // length >  10: SQL Timestamp, assumes PGDATESTYLE=ISO
!         try {
!            return java.sql.Date.valueOf((s.length() == 10) ? s :
s.substring(0,10));
!         } catch (NumberFormatException e) {
!            throw new PSQLException("postgresql.res.baddate", s);
!         }
      }

      public static Time toTime(String s) throws SQLException

Diff finished at Fri Nov 09 08:47:03

Daniel

> -----Original Message-----
> From: Barry Lind [mailto:barry@xythos.com]
> Sent: November 8, 2001 10:50 PM
> To: Daniel Germain
> Cc: pgsql-jdbc@postgresql.org
> Subject: Re: ResultSet.getDate failure with timestamp column
>
>
> Daniel,
>
> You are correct.  Version 1.29 backed out the previous fix.  I will fix
> this when I get a chance (unless you want to submit a patch and save me
> some time?).
>
> thanks,
> --Barry
>
> Daniel Germain wrote:
>
> > Hi,
> >
> > I'm trying to migrate an existing application to postgresql
> > that uses generated code for accessing the database layer.
> >
> > I search the mailing list and found other references to that problem
> > which seems to have been fixed in Revision 1.26 of ResultSet.java
> > and seems to be removed in Revision 1.29
> >
> > Here is the stack trace with the DevelopmentDriver 7.2dev
> (built 2001-10-31)
> >
> > java.lang.NumberFormatException: 04 00:00:00-04
> >     at java.lang.Integer.parseInt(Integer.java:414)
> >     at java.lang.Integer.parseInt(Integer.java:454)
> >     at java.sql.Date.valueOf(Date.java:91)
> >     at org.postgresql.jdbc2.ResultSet.toDate(ResultSet.java:1557)
> >     at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:372)
> >     at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:607)
> >
> >
> > Any good reason why it was removed? It seems to be contrary to the
> > spec from what I read in this mailing list.
> >
> > Thanks
> >
> > Daniel
> >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> >
> >
>
>



QueryExecutor NullPointerException invalid Connection?

From
"Daniel Germain"
Date:
Hi,

We keeps having these kind of random errors.

*** Caused by:
java.lang.NullPointerException
    at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)
    at org.postgresql.Connection.ExecSQL(Connection.java:376)
    at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
    at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
    at
org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.java:9
9)
    at
com.lutris.dods.builder.generator.query.QueryBuilder.executeQuery(QueryBuild
er.java:1541)

*** Caused by:
java.lang.NullPointerException
    at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)
    at org.postgresql.Connection.ExecSQL(Connection.java:398)
    at org.postgresql.Connection.ExecSQL(Connection.java:381)
    at org.postgresql.Connection.setAutoCommit(Connection.java:834)
    at
com.lutris.appserver.server.sql.standard.StandardDBConnection.reset(Standard
DBConnection.java:285)

QueryExecutor:
    public java.sql.ResultSet execute() throws SQLException
    {

        int fqp = 0;
        boolean hfr = false;

line 61->        synchronized (pg_stream)


From my investigation pg_stream is set to null when ever a connection is
closed.

We are using the lastest "Developement driver" from CVS 2001/12/20.
We are not using the lastest stable PostgreSQL 7.1.x Java 2 drivers
since we need some patches that were applied only on the developement
version.
We are using Enhydra3.1 from Lutris as the database layer and everything
is working fine with the same code but with Microsoft SQLServer, so my guess
is that this problem is more Postgres related than Enhydra. I was not able
to find any reference to this problem elsewhere.

Enhydra manages its own connection pool, and check if the database
connection
is valid and remove it when appropriate but for some reason it seem to get
and
invalid one with this null pointer.

TIA

Daniel





Re: QueryExecutor NullPointerException invalid Connection?

From
"Dave Cramer"
Date:
Daniel,

The problem is likely in how Enhydra/posgtres is determing if the
connection is valid or not. Do you know how this is done?

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Daniel Germain
Sent: Friday, December 21, 2001 1:59 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] QueryExecutor NullPointerException invalid Connection?


Hi,

We keeps having these kind of random errors.

*** Caused by:
java.lang.NullPointerException
    at
org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)
    at org.postgresql.Connection.ExecSQL(Connection.java:376)
    at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
    at
org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
    at
org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.ja
va:9
9)
    at
com.lutris.dods.builder.generator.query.QueryBuilder.executeQuery(QueryB
uild
er.java:1541)

*** Caused by:
java.lang.NullPointerException
    at
org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)
    at org.postgresql.Connection.ExecSQL(Connection.java:398)
    at org.postgresql.Connection.ExecSQL(Connection.java:381)
    at org.postgresql.Connection.setAutoCommit(Connection.java:834)
    at
com.lutris.appserver.server.sql.standard.StandardDBConnection.reset(Stan
dard
DBConnection.java:285)

QueryExecutor:
    public java.sql.ResultSet execute() throws SQLException
    {

        int fqp = 0;
        boolean hfr = false;

line 61->        synchronized (pg_stream)


From my investigation pg_stream is set to null when ever a connection
>is
closed.

We are using the lastest "Developement driver" from CVS 2001/12/20. We
are not using the lastest stable PostgreSQL 7.1.x Java 2 drivers since
we need some patches that were applied only on the developement version.
We are using Enhydra3.1 from Lutris as the database layer and everything
is working fine with the same code but with Microsoft SQLServer, so my
guess is that this problem is more Postgres related than Enhydra. I was
not able to find any reference to this problem elsewhere.

Enhydra manages its own connection pool, and check if the database
connection is valid and remove it when appropriate but for some reason
it seem to get and invalid one with this null pointer.

TIA

Daniel





---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org