my dog learned polymorphism*
The moose likes JDBC and the fly likes Delay  of 5 minutes and 40 seconds Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Delay  of 5 minutes and 40 seconds" Watch "Delay  of 5 minutes and 40 seconds" New topic
Author

Delay of 5 minutes and 40 seconds

Amer Seifeddine
Ranch Hand

Joined: Apr 25, 2002
Posts: 57
Hi,

I have sql server 2000 and simple resultset.

SQL:
every date after or equals 1920/01/01 is perfect for below issue however a date with this selection:

select cast('1919-12-31 09:10:45.000' as datetime)

returns using a JDBC and resultset.getTimestamp method a correct date (wrong time) but with 5 minutes and 40 seconds delay eg.

1919-12-31 09:05:05.0.

Do you have a logical effective explanation or fix? Thanks a lot.

Driver: TDS Driver for SQL Server 2003 SP3
Java: SDK 1.4.2
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You are casting a string to a timestamp in SQL, which would use SQL's default timezone. Then (I assume, I don't see any code but you mention Java) you format that timestamp as a string in Java, which would use Java's default timezone. So, what are those two default timezones?
Amer Seifeddine
Ranch Hand

Joined: Apr 25, 2002
Posts: 57
All what i did in a very simple java program is:

System.out.println(rs.getTimestamp (1)+"");

I had a workaround by selecting time as character and that worked!
 
Don't get me started about those stupid light bulbs.
 
subject: Delay of 5 minutes and 40 seconds
 
Similar Threads
Websphere 6.0.2 localhost 9080 does not connect
ORA-01861: literal does not match format string
oracle date between
Problem with SQL DATE() function..
What's wrong with Date data from Oracle 9i?