Thread: jdbc, Dates, and JBuilder

jdbc, Dates, and JBuilder

From
Dallas Hockley
Date:
Got a wee problem here, and I'm having a devil of a time locking it
down....

Using 6.3.1 Postgresql, with the accompanying jdbc driver, and using
Jbuilder 1.01 and 2.0, I am reading in a string, converting it to
a valid and correct sql.date, putting that into a DataRow instance
(Borland class) and committing the row to the database.  The data is
correct in the data row as it prepares for the commit.

After insert, when the row is retrieved, the day is consistently 1 too
large.  e.g. 04-14-1998 becomes 04-15-1998 after it's been committed via
the jdbc driver.  What I'm not sure of is if it's the driver, the
database, the datarow class or some interface between two of them.

Has anyone experienced similar behaviour, or has anyone got a definitive
"it can't be ..... because.... "

I'd appreciate any assistance on this.

Thanks in advance,

Dallas Hockley
hockleyd@cybersoft.ab.ca

Re: [INTERFACES] jdbc, Dates, and JBuilder

From
Peter Mount
Date:
On Wed, 24 Jun 1998, Dallas Hockley wrote:

> Got a wee problem here, and I'm having a devil of a time locking it
> down....
>
> Using 6.3.1 Postgresql,

Get hold of the 6.3.2 version of the driver, as there were a lot of
JBuilder related additions to it since 6.3.1 (it will work with 6.3.1
backends).

> with the accompanying jdbc driver, and using
> Jbuilder 1.01 and 2.0, I am reading in a string, converting it to
> a valid and correct sql.date, putting that into a DataRow instance
> (Borland class) and committing the row to the database.  The data is
> correct in the data row as it prepares for the commit.
>
> After insert, when the row is retrieved, the day is consistently 1 too
> large.  e.g. 04-14-1998 becomes 04-15-1998 after it's been committed via
> the jdbc driver.  What I'm not sure of is if it's the driver, the
> database, the datarow class or some interface between two of them.

This is an old Java bug that I thought I had got rid of. The
java.util.Date class seems to loose a day somewhere in the conversion
(at least this is with JDK1.1.3 which I still use).

> Has anyone experienced similar behaviour, or has anyone got a definitive
> "it can't be ..... because.... "

No, it's definitley in there.

I thought I had got rid of it by adding one to the day in ResultSet... it
looks like I'll have to add "fix Date support" to the list of things to
work on again.

--
Peter Mount, peter@maidstone.gov.uk
Postgres email to peter@taer.maidstone.gov.uk & peter@retep.org.uk
Remember, this is my work email, so please CC my home address, as I may
not always have time to reply from work.



Re: [INTERFACES] jdbc, Dates, and JBuilder

From
Dallas Hockley
Date:
Peter Mount wrote:
>
> On Wed, 24 Jun 1998, Dallas Hockley wrote:
[snip]
>
> This is an old Java bug that I thought I had got rid of. The
> java.util.Date class seems to loose a day somewhere in the conversion
> (at least this is with JDK1.1.3 which I still use).
>
> > Has anyone experienced similar behaviour, or has anyone got a definitive
> > "it can't be ..... because.... "
>
> No, it's definitley in there.
>
> I thought I had got rid of it by adding one to the day in ResultSet... it
> looks like I'll have to add "fix Date support" to the list of things to
> work on again.
>

Thanks for the quick reply Peter, although there is one thing I forgot
to mention.

It appears the conversion on the insert is where the glitch was
introduced, as psql returns the altered date as well as a jdbc query.
The two are in agreement, but they are both not correct with respect to
the data that was inserted.

I will upgrade the driver though.... thanks.


Dallas

hockleyd@cybersoft.ab.ca

> --
> Peter Mount, peter@maidstone.gov.uk
> Postgres email to peter@taer.maidstone.gov.uk & peter@retep.org.uk
> Remember, this is my work email, so please CC my home address, as I may
> not always have time to reply from work.

Re: [INTERFACES] jdbc, Dates, and JBuilder

From
Peter Mount
Date:
On Thu, 25 Jun 1998, Dallas Hockley wrote:
> It appears the conversion on the insert is where the glitch was
> introduced, as psql returns the altered date as well as a jdbc query.
> The two are in agreement, but they are both not correct with respect to
> the data that was inserted.

Yes it seems to be the java.util.Date's constructor that's at fault here.

--
Peter Mount, peter@maidstone.gov.uk
Postgres email to peter@taer.maidstone.gov.uk & peter@retep.org.uk
Remember, this is my work email, so please CC my home address, as I may
not always have time to reply from work.