• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wrong time retrieved in the resultset- MS SQL Server 2000

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using jtds-1.1.jar as a SQL Server Driver to connect to MS SQL Server
2000. I have the following 2 columns in a table.

Job_Start_Time(datetime,null) | Job_End_Time(datetime,null)
------------------------------------------------------------------------
1900-01-01 20:00:00.000 | 1900-01-02 04:00:00.000

When I try to retrieve this data using rs.getTime("Job_Start_Time") and
rs.getTime("Job_End_Time"), I am getting it 20:23:20 and 04:23:20
respectively.

Can anyone let me know the workaround or anything that I'm missing out on?

Thanks
-Amod
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to get them with rs.getString() or as a object and see whether the actual data has been fetched or not !
 
amod god
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sagar,

Thanks for your reply.

I have checked that. Even, I have tried with rs.getTimestamp() but the result presists.

-Amod
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the time difference change, or is it always 23 minutes 20 seconds?

 
amod god
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

Most of the times, it does. Generally, I retrieve these timings and display it on the web page(form). If I click on the save button, it saves 900-01-01 20:23:00.000 | 1900-01-02 04:23:00.000 in the database.

Sometimes, I do get 20:46 and 04:46 when I retrieve the same record. I'm watching that there is pattern(difference of 23)

I don't care about the seconds as of now.

Thanks
-Amod
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it 20:46:40 and 04:46:40?
 
amod god
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, it's 20:46:20 and 04:46:20.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried this with Microsoft's JDBC driver? jTDS does some work to produce a DateTime object - trying it with a different driver would be a quick test to see if there is a driver bug (though its not one I know of in jTDS).
 
amod god
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul.

Let me check with that driver.

Regards
-Amod
 
amod god
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Paul,

It looks like we are through. My initial testing with Microsoft's driver is successful. But as per the requirement, I *have* to use the jTDS driver. Let me check with the later version of jTDS driver.

Thanks a lot for your suggestion.

Regards,
-Amod
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting requirement! I suppose at least you can deliver your software exactly as specified with the error in it. I'd speak to whoever wrote the requirement and ask why jTDS is required. I can understand why you would use jTDS over the old MS SQL Server 2000 driver - it was bug ridden, largely unsupported (MS bough the code from someone else and had no legal rights to update it) and undistributable (for the same reason). But now of those issues exist with the newer driver.

Have you checked jTDS JIRA? They might have a patch.
 
amod god
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, the application is being integrated with the other one. So, we have to make sure that both the applications are using the same driver.(and its a JTDS ) I tried with jTDS1.2.2 jar file but the result remains the same.

I couldn't find any solution in JIRA. I will have to continue with my *research* on this.

Regards,
-Amod
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the DDL of the table.

It would also be helpful if you cut down the whole thing into an SSCCE and post it here.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

amod god wrote:Actually, the application is being integrated with the other one. So, we have to make sure that both the applications are using the same driver.(and its a JTDS ) I tried with jTDS1.2.2 jar file but the result remains the same.

I couldn't find any solution in JIRA. I will have to continue with my *research* on this.

Regards,
-Amod



jTDS is open source. Have you tried debugging into the source? You may have stumbled on a genuine bug (though jTDS has been fairly stable for quite some time now).

Bauke - I'm guessing SSCCE stands for "Short Self-Contained Correct Example"?
 
amod god
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul and Bauk,

Now, this is very weird. I tried it by including the following line in the source code.

public Time getTime(int columnIndex) throws SQLException {
System.out.println("jtds time = "+Support.convert(this, getColumn(columnIndex), java.sql.Types.TIME, null));
return (java.sql.Time) Support.convert(this, getColumn(columnIndex), java.sql.Types.TIME, null);
}

And, it gives me the correct result. So I guess, Am I running into some jar conflict?

Thanks
-Amod
 
reply
    Bookmark Topic Watch Topic
  • New Topic