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 preparedStatement.setDate and java.util.Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "preparedStatement.setDate and java.util.Date" Watch "preparedStatement.setDate and java.util.Date" New topic
Author

preparedStatement.setDate and java.util.Date

hani Ibrahim
Ranch Hand

Joined: Sep 06, 2006
Posts: 182
i tried to setDate for preparedStatement and piyt in it java.util.Date object but it is falied at compile time,if make cast to it at runtime exception cast exception.
how to send java.util.Date to DB please
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

As can be seen from the javadoc api, PreparedStatement.setDate() is accepting java.sql.Date object..not java.util.Date.
hani Ibrahim
Ranch Hand

Joined: Sep 06, 2006
Posts: 182
i know that because of that i asked how to send Date from java to Database?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14144
    
  18

Convert your java.util.Date object to a java.sql.Date object:



Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: preparedStatement.setDate and java.util.Date