File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes SQl Server error converting datetime to smalldatetime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQl Server error converting datetime to smalldatetime" Watch "SQl Server error converting datetime to smalldatetime" New topic
Author

SQl Server error converting datetime to smalldatetime

Vijay Bala
Greenhorn

Joined: Oct 25, 2001
Posts: 25
Hi,
I am using a SQL Server stored proc.I am trying to update a smalldatetime column and get the error "error converting datetime to smalldatetime". Another smalldatetime column in the table has the format "yyyy-mm-dd hh:mm:ss".
I tried the foll code:
long i = drvo.getDateOfBirth().getTime();//getDateOfBirth returns a java.util.Date
call.setDate(1,new java.sql.Date(i));
//call.setTimestamp(1,new java.sql.Timestamp(i));
Using both the setDate and setTimestamp gave me the same error.I am using the sql server type 4 driver for 7.0.I tried using Resultsetmetadata and got the column type to be Timestamp from the table.Its defined as smalldatetime in the table.
Thanx in advance for any help,
Vijay
sahana sah
Greenhorn

Joined: Dec 04, 2007
Posts: 1
I have got the same problem. Any one to help??
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29237
    
139

"sahana2007",
Please check your private messages for a message from me.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQl Server error converting datetime to smalldatetime
 
Similar Threads
JDBC and smalldatetime - ms sql server 2008
java.util.Date to java.sql.Date
java sql TYPE
data type mapping between POJO class and database data type
error in servlet