Comment puis-je réparer java.SQL.L'exception BatchUpdateException?
J'écris un programme java qui se connecte à mysql db avec jdbc.It insère des enregistrements dans mysql. Le sql est le suivant:
INSERT INTO my_schema.my_table VALUES ('AMERICAN', '97', '1995-08-28 00:00:00', '10', '1995-08-28 00:00:00', '10', 'United States Dollar', 'USD', '$', '2', 'Y', 'Y', '1995-08-28 00:00:00', '_6064530F8DBAB938E040007F010015E3' );
Mais cela donne cette erreur:
e = (java.sql.BatchUpdateException) java.sql.BatchUpdateException: 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 '('AMERICAN', '40', '1995-08-28 00:00:00', '10', '1995-08-28 00:00:00', '10', 'Ja' at line 1
Mais la chose étrange est : je l'insère manuellement sans erreur.
Merci d'avance,
1
Author: Ersin Gülbahar, 2014-04-22
1 answers
C'est bizarre mais ça fonctionne:
Je supprime simplement le dernier caractère point-virgule , et cela fonctionne:
Je veux dire que je change ceci:
INSERT INTO my_schema.my_table VALUES ('AMERICAN', '97', '1995-08-28 00:00:00', '10', '1995-08-28 00:00:00', '10', 'United States Dollar', 'USD', '$', '2', 'Y', 'Y', '1995-08-28 00:00:00', '_6064530F8DBAB938E040007F010015E3' );
À ceci:
INSERT INTO my_schema.my_table VALUES ('AMERICAN', '97', '1995-08-28 00:00:00', '10', '1995-08-28 00:00:00', '10', 'United States Dollar', 'USD', '$', '2', 'Y', 'Y', '1995-08-28 00:00:00', '_6064530F8DBAB938E040007F010015E3' )
1
Author: Ersin Gülbahar, 2014-04-22 08:11:02