hi,
When I try to save a date in to a date field I get the following error:
Cannot assign an object of type java.lang.String to host variable 3 which has JDBC type DATE.
The solution I used worked fine but we I changed my application to use DAO and datasources I get to error.
following is my code i use.
public void createTitle(int title_id, String description, String user)
throws SQLException {
// TODO Auto-generated method stub
Date date = new Date();
String dateFormat = "yyyy-MM-dd";
String timeFormat = "HH:mm:ss";
SimpleDateFormat ddf = new SimpleDateFormat(dateFormat);
SimpleDateFormat tdf = new SimpleDateFormat(timeFormat);
String creationDate = ddf.format(date);
String creationTime = tdf.format(date);
PreparedStatement newTitle = conn.prepareStatement("INSERT INTO BE_TITLE (TITLE_ID, DESCRIPTION, DATE_CREATE, USER_CREATE) VALUES (?,?,?,?,?)");
try{
newTitle.setInt(1,title_id);
newTitle.setString(2,description);
newTitle.setString(3,creationDate);
newTitle.setString(4,creationTime);
newTitle.setString(5, user);
newTitle.executeUpdate();
}finally{
newTitle.close();
}
}
What is wrong and please give me a solotion.
Kind Regards,
Richard