Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC and smalldatetime - ms sql server 2008

 
Thomas D Kim
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to insert a record. one field is described as smalldatetime on a table in ms sql server 2008. I am using the prepared statement to insert the record. for example, if i am getting the data from a textfield on a panel, my code is like this:


I am getting "conversion from datetime data type to smalldatetime data type resulted in a smalldatetime overflow error". I am using jtds driver.

Can you help?

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Smalldatetime can't store as much data as datetime, hence the error. smalldatetime is SQL Server specific data type so if you want to use it you'll need to use the driver-specific classes to support it. jTDS has a DateTime class to do conversions.
 
Thomas D Kim
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,

Thanks for a quick reply.

I am having a problem with the jtds DateTime class. Apparently their constructors are all private and i don't know how to access it.

Can you give me an example?


Thanks,

Thomas Kim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic