java - Exception while input a date into a MySQL database -
i have mysql
database , want write row it. problem mysql
not query
, why? code:
java.sql.timestamp date = new java.sql.timestamp(new java.util.date().gettime()); (integer articlevalue : articlesendlist) { (integer suppliervalue : suppliersendlist) { connection.executequery("insert bestellungen(bestellung_id, artikel_id, lieferant_id, datum, preis) values (" + maxorder + ", " + articlevalue + ", " + suppliervalue + ", " + date + ", null)"); } }
a small description code. articlesendlist
contains ids selected values jtabel
. same applies suppliersendlist
. want write ids table "bestellung
". variable maxorder
current id table "bestellung
".
if need it, exception is:
you have error in sql syntax; check manual corresponds mysql server version right syntax use near '12:45:06.164, null)' @ line 1
please not comment/answer other links, searched problem , read several sites. not me or not suitable problem.
- thank help
try changing line:
connection.executequery("insert bestellungen(bestellung_id, artikel_id, lieferant_id, datum, preis) values (" + maxorder + ", " + articlevalue + ", " + suppliervalue + ", " + date + ", null)");
to this:
connection.executequery("insert bestellungen(bestellung_id, artikel_id, lieferant_id, datum, preis) values ('" + maxorder + "','" + articlevalue + "','" + suppliervalue + "','" + date + "','null')");
Comments
Post a Comment