aspose file tools*
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
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: 18566
    
    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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Delay of 5 minutes and 40 seconds