Link to home
Start Free TrialLog in
Avatar of gla
gla

asked on

java.sql.date problem

I use  j2ee 1.3.1  with  jdk1.4.1 on a Solaris SPARC and have the following problem:

From any application client from a field type java.sql.date hardly I make  update  date '2003-03-20' it store in the data base as '2003-03-19'.


Which problem exists, it is bug?


Thanks



George Liolios
Avatar of Mayank S
Mayank S
Flag of India image

I am sorry but I don't understand your question very well. I guess that if you wnat to store 2003-03-20, then it is storing 2003-03-19, right?

Mayank.
Avatar of gla
gla

ASKER

Exactly,

When user write in text field 2003-03-20 and press the update button, then it is stored 2003-03-19.

I think the problem is combined between client and j2ee server.



I tryied to prin
Is it happening with all the dates?? I mean, try the extremes like:

2003-05-31
2003-02-28

Also, try 2003-02-29 and 2003-05-32 and see what it writes.

Mayank.
 I do not think it is a bug but you can always check the bug database here: http://java.sun.com/j2se/1.4/fixedbugs/index.html

  I'd say it's a database problem. Can you check the configurations/manuals of your database and see if you can find anything weird?
try storing the date with # around them like this: #2003-03-20#
Maybe it's a problem of Time Zone settings of Database server?
> Maybe it's a problem of Time Zone settings of Database server?

  It shouldn't though since the database is supposed to store whatever receives from the client. Even if the time zone is different on the database server the value it receives from the client should not conflict with the server.
Check , if you have ON UPDATE trigger on that table, that decrease a day from the requested value of the date, while updating date column in that table..
Whats the type in the database, and how are you storing and retrieving it.
Avatar of gla

ASKER

I use an Oracle 8i Second Edition on a Linux Intel Rehat Server.

I User Container Managed Persisted EJB 's to STORE and Retrieve Data.

For your help if I use the J2EE 1.3 and not J2EE 1.3.1 then
all is fine
Avatar of gla

ASKER

I use an Oracle 8i Second Edition on a Linux Intel Rehat Server.

I User Container Managed Persisted EJB 's to STORE and Retrieve Data.

For your help if I use the J2EE 1.3 and not J2EE 1.3.1 then
all is fine
 Why don't you stick with J2EE 1.3 then?
Avatar of gla

ASKER

>Is it happening with all the dates?? I mean, try the >extremes like:

>2003-05-31
>2003-02-28

>Also, try 2003-02-29 and 2003-05-32 and see what it writes.

>Mayank.

I tried 2003-05-32 and I retrieve 2003-05-31
also 2003-02-29 and I retrieve 2003-02-28


George
Avatar of gla

ASKER

>Is it happening with all the dates?? I mean, try the >extremes like:

>2003-05-31
>2003-02-28

>Also, try 2003-02-29 and 2003-05-32 and see what it writes.

>Mayank.

I tried 2003-05-32 and I retrieve 2003-05-31
also 2003-02-29 and I retrieve 2003-02-28


George
>> I tried 2003-05-32 and I retrieve 2003-05-31

Then probably the only thing you can do is increment the day by one and then insert the date for every transaction :-)

Mayank.
Something makes me feel that this is a Locale problem..

Mayank.
Are your sure that your time-zone settings at the client and server sides match?

Mayank.
Avatar of gla

ASKER

Yes I am sure the time-zone match.

George

Then I think its just that the server is taking the date to be one day before the actual date. Guess its a very hard-to-debug problem unless we actually get to see it!

Mayank.
Avatar of gla

ASKER

Yes I am sure the time-zone match.

George

Avatar of gla

ASKER

Mayank

I remind you that with the j2ee1.3 working fine!


George.
 It shouldn't be a time-zone problem since the db server inserts the value it receives from client (whatever this value is).

  gla whta's the issue of using 1.3 instead of 1.3.1?
Avatar of gla

ASKER

Mayank

I remind you that with the j2ee1.3 working fine!


George.
Avatar of gla

ASKER

The reasons of using j2ee 1.3.1 is
Performance improvement running enterprise beans and
I use Sun One studio update 1 that working with j2ee 1.3.1

George
1.
can u insert the date to the database manually. see how the db reacts to that.

2.
create another simple application and use a JTextField and write the proper date in that field then .getText() and insert that in the db and see.

3.
if possible use other application (in java) to  insert dates.

4.
if possible use other application (not in java) to  insert dates.

5.
when inserting other value (other than dates) are the results ok ?

6.
when you do enter the date, and server stores wrong data, dont do any thing simply commit and then retrieve that data is it showing it right or not ?
And you still haven't told us what the database type of the date in the database is.
Avatar of gla

ASKER

The database (Ora8i) field type is date.

If i insert a row in database manually everthing is fine.

After many test with j2ee and jdk on solaris sparc.


I see that:

a. compine j2ee1.3.1 and jdk1.4.1 on solaris sparc:

dates
17/10/1950
17/10/1960
17/10/1970
17/10/1980
17/10/1990
17/10/2000

stored fine.

dates
17/10/1974

stored 16/10/1974

a. compine j2ee1.3.1 and jdk1.3_02 on linux redhat 7.0:

all dates working fine!

Please note that the database server is on defered machine than application server (j2ee)!

 
George Liolios


Avatar of gla

ASKER

The database (Ora8i) field type is date.

If i insert a row in database manually everthing is fine.

After many test with j2ee and jdk on solaris sparc.


I see that:

a. compine j2ee1.3.1 and jdk1.4.1 on solaris sparc:

dates
17/10/1950
17/10/1960
17/10/1970
17/10/1980
17/10/1990
17/10/2000

stored fine.

dates
17/10/1974

stored 16/10/1974

a. compine j2ee1.3.1 and jdk1.3_02 on linux redhat 7.0:

all dates working fine!

Please note that the database server is on defered machine than application server (j2ee)!

 
George Liolios


Avatar of gla

ASKER

The database (Ora8i) field type is date.

If i insert a row in database manually everthing is fine.

After many test with j2ee and jdk on solaris sparc.


I see that:

a. compine j2ee1.3.1 and jdk1.4.1 on solaris sparc:

dates
17/10/1950
17/10/1960
17/10/1970
17/10/1980
17/10/1990
17/10/2000

stored fine.

dates
17/10/1974

stored 16/10/1974

a. compine j2ee1.3.1 and jdk1.3_02 on linux redhat 7.0:

all dates working fine!

Please note that the database server is on defered machine than application server (j2ee)!

 
George Liolios


Avatar of gla

ASKER

The database (Ora8i) field type is date.

If i insert a row in database manually everthing is fine.

After many test with j2ee and jdk on solaris sparc.


I see that:

a. compine j2ee1.3.1 and jdk1.4.1 on solaris sparc:

dates
17/10/1950
17/10/1960
17/10/1970
17/10/1980
17/10/1990
17/10/2000

stored fine.

dates
17/10/1974

stored 16/10/1974

a. compine j2ee1.3.1 and jdk1.3_02 on linux redhat 7.0:

all dates working fine!

Please note that the database server is on defered machine than application server (j2ee)!

 
George Liolios


ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
gla:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.