gpt4 book ai didi

java - 如何修复 java.sql.BatchUpdateException?

转载 作者:行者123 更新时间:2023-11-29 00:15:11 27 4
gpt4 key购买 nike

我编写了一个 java 程序,它使用 jdbc 连接到 mysql 数据库。它将记录插入到 mysql。sql是这样的:

 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' );

但它给出了这个错误:

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

但奇怪的是:我手动插入它没有错误。

提前致谢,

最佳答案

这很奇怪,但它有效:

我只是删除了最后一个字符 semicolon ,它起作用了:

我的意思是我改变这个:

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' );

为此:

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' )

关于java - 如何修复 java.sql.BatchUpdateException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23212949/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com