Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PreparedStatement SetObject Invalid data conversion exception

843859Aug 22 2007 — edited Nov 20 2014
Hi guys. I am trying to use setObject method in preparedstatement to associate an Object with a PreparedStatement.
conn = this.getConnection();
ps = conn.prepareStatement(sql);
ps.setObject(1, new Date());
The problem is that the code above fails with SQLException:
Invalid data conversion: Parameter object type is invalid for requested conversion.

I thought that the setObject will auto-map the object to the relevant data type (in this case java.sql.Date)...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 3 2007
Added on Aug 22 2007
14 comments
964 views