PreparedStatement « Date « Java Database Q&A

1. String to Date in a PreparedStatement

I am trying to use setDate() in a PreparedStatement, however the date that I have is in the format of 2008-07-31. The code is:

 pstmt.setDate(f++, (Date) DateFormat.getDateInstance(DateFormat.DEFAULT).parse(value.substring(0, 10)));
However, it gives me ...

3. Problems setting sql Date in prepared statement

I genuinely thought I had posted this into the beginner forum, as I didn't want to waste anyone's time and I am new-ish to Java, so I have assumed my problem is due to inexperience, though I have been programming for 30+ years now on many other platforms. Sorry if my last post sounded harsh, the last thing I want to ...

4. convert String to date and pass to PreparedStatement

Ok, here is my problem I am retrieving a date from a web page that returns a date in the format '2010-09-12' as string from a text box. What I want to do is convert it to a date and pass it in a PreparedStatement to handle it. How can I do this?

5. set date TO_DATE() in preparedstatement