aspose 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

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "preparedStatement.setDate and java.util.Date" Watch "preparedStatement.setDate and java.util.Date" New topic

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: 14423

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

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: preparedStatement.setDate and java.util.Date