我已经开发了一个Java应用程序,用于读取给定的xml文件,并使用xml文件中的数据创建SQL INSERT or UPDATE statements。好玩的是,下面有一些陈述。

INSERT INTO BUYERS(BUYER_ID, BUYER_NAME) VALUES ('100', 'A's Shop')
INSERT INTO BUYERS(BUYER_ID, BUYER_NAME) VALUES ('101', 'ABC's Shop')
INSERT INTO BUYERS(BUYER_ID, BUYER_NAME) VALUES ('102', 'ZXCVBN's Shop')
INSERT INTO BUYERS(BUYER_ID, BUYER_NAME) VALUES ('103', 'RR's Shop')

UPDATE BUYERS SET BUYER_NAME = 'MKO's Shop' WHERE BUYER_ID = 151
UPDATE BUYERS SET BUYER_NAME = 'DDD's Shop' WHERE BUYER_ID = 160


当我尝试执行这些语句时,出现ORA-00917: missing comma错误,因为single quote的值为BUYER_NAME

我试图在Java中使用single quote方法替换此replace(char oldChar, char newChar)。但它将替换我查询中的所有single quotes

我只需要用single quote替换BUYER_NAME。我该怎么办?

最佳答案

使用prepareStatement()尝试一下。

10-08 04:00