Originally posted by Deyna Cegielski:
my mysql database stored dates as strings in the format dd/mm/yyyy.
im having problems inserting into the database because the values i want to insert for the date are from a jformattedtextfield with simpledateformat("dd/mm/yy). i get a haunch of errors because of this.
any ideas how to get around this?
thanks
Are you saying that you are storing date information into a column of
string type? If so, that's a big part of your problem. Use an appropriate date or time type:
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-types.html Or are you saying that you're using a date type and when you send MySQL a string that represents a date, it can't convert it? That's a different problem. You shouldn't rely on a database to do implicit type conversion for you; they all do it a little differently for one thing. Instead, first convert your date string to a java.util.Date in
Java. Then second, use a PreparedStatement, and the setDate method.