0
String a = "insert into movie values('"+w[0]+"','"+w[1]+"','"+w[2]+
                                "',STR_TO_DATE('"+w[3]+"','%y-%m-%d'),'"+w[4]+"','"
                                +w[5]+"','"+w[6]+"','"+w[7]+"','"+w[8]+"');";
  1. w[3] is date type which is like 2019-12-25
  2. I got error message : Incorrect datetime value: '(?)???????????(NEW)' for function str_to_date
  3. What am I missing??
Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
mark
  • 1
  • 6
    maybe use parameterized queries ? – Cid Nov 17 '19 at 10:33
  • 4
    Do not ever concatenate values in to a query string. It makes your code vulnerable to SQL injection. Use prepared statements with parameters. In any case, if the error is `Incorrect datetime value: '(?)???????????(NEW)'`, then it looks like `w[3]` has value `(?)???????????(NEW)`. – Mark Rotteveel Nov 17 '19 at 10:43
  • Possible duplicate of [Insert & fetch java.time.LocalDate objects to/from an SQL database such as H2](https://stackoverflow.com/questions/43039614/insert-fetch-java-time-localdate-objects-to-from-an-sql-database-such-as-h2) – Ole V.V. Nov 17 '19 at 10:52
  • The information you have provided so far doesn’t reveal any reason for the error message you are quoting. You may well want to [create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) including the name (and version) of your RDBMS and the schema of your table. – Ole V.V. Nov 17 '19 at 11:27

0 Answers0