aspose file tools*
The moose likes JDBC and the fly likes JDBC and smalldatetime - ms sql server 2008 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC and smalldatetime - ms sql server 2008" Watch "JDBC and smalldatetime - ms sql server 2008" New topic
Author

JDBC and smalldatetime - ms sql server 2008

Thomas D Kim
Greenhorn

Joined: Jul 09, 2008
Posts: 3
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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Thomas D Kim
Greenhorn

Joined: Jul 09, 2008
Posts: 3
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JDBC and smalldatetime - ms sql server 2008