0

I'm getting this exception:

com.ibm.db2.jcc.c.SqlException: The syntax of the string representation of a datetime value is incorrect

while trying to apply java.sql.Date in the format yyyy-mm-DD as the value 2011-12-28 in the Java Code.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Rakesh Sabbani
  • 1,655
  • 5
  • 17
  • 31
  • 2
    what is the code that's causing this exception. Also, people will be more likely to help you if you accept more (than 53%) of the answers provided. – Ramy Dec 30 '11 at 06:18

1 Answers1

0

Try to use PreparedStatement.setDate() method.

For instance,

String date="2011-12-28";
PreparedStatement ps=con.prepareStatement("INSERT INTO Table1 (Col1) VALUES (?)");
ps.setDate(1,java.sql.Date.valueOf(date));
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186