I have a MySQL
database and want to write a row into it. The problem is that MySQL
do not like my query
, why? This is my code:
java.sql.Timestamp date = new java.sql.Timestamp(new java.util.Date().getTime());
for (Integer articlevalue : articlesendlist) {
for (Integer suppliervalue : suppliersendlist) {
connection.executeQuery("INSERT INTO Bestellungen(Bestellung_ID, Artikel_ID, Lieferant_ID, Datum, Preis) VALUES (" + maxorder + ", " + articlevalue + ", " + suppliervalue + ", " + date + ", NULL)");
}
}
A small description for my code. The articlesendlist
contains IDs from selected values from a JTabel
. The same applies to the suppliersendlist
. I want to write the IDs into the table "Bestellung
". The variable maxorder
is the current ID for the table "Bestellung
".
If you need it, the exception is:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '12:45:06.164, NULL)' at line 1
Please do not comment/answer with other links, I already searched for the problem and read several sites. They do not help me or are not suitable for my problem.
- Thank you for help