JDBC执行期间出现MySQL意外语法错误

时间:2016-09-04 08:35:40

标签: java mysql jdbc syntax-error

我正在通过我编写的Java Web服务执行脚本,以便在MySQL数据库上执行。 在phpMyAdmin中执行查询时,它成功完成,但是一旦我的Web服务执行它,它就会返回:

  

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException:SQL语法中有错误;检查与MySQL服务器版本对应的手册,以便在第1行的'SELECT @ OBJECTIVE_1_DESCRIPTION:= OBJECTIVE_DESCRIPTION,@ OBJECTIVE_1_LVL:= OB'附近使用正确的语法

以下查询作为从.sql文件读取的预准备语句执行:

(这只是相关代码的一小部分,我添加了新行来提高可读性,在实际文件中查询后每行只有新行“;”)

SET @USER_ID = ?, 
@EMAIL = ?, 
@NAME = ?, 
@SURNAME = ?, 
@SUBURB = ?, 
@CITY = ?, 
@PASSWORD = ?, 
@RELIABLE_OCR_RESULTS = 0, 
@HOUSEHOLD_SIZE = 0, 
@DATE = NOW(), 
@OBJECTIVE_1_ID = '4E2DEA7B-037A-4958-8696-2B73EDD3E08E', 
@NEW_OBJECTIVE_1_ID = 'E46027A1-CE36-4413-9E64-7A217FFB9CEB', 
@OBJECTIVE_1_DESCRIPTION = REPLACE(@OBJECTIVE_1_DESCRIPTION, '*', @OBJECTIVE_1_TARGET), 
@OBJECTIVE_1_PROGRESS  = 0.0,  
@OBJECTIVE_1_COMPLETED  = 0, 
@COMPLETED_OBJECTIVES = NULL, 
@NEW_OBJECTIVE_1_DESCRIPTION = REPLACE(@NEW_OBJECTIVE_1_DESCRIPTION, '*', @NEW_OBJECTIVE_1_TARGET), 
@NUM_COMPLETED_OBJECTIVES = 0;

SELECT @OBJECTIVE_1_DESCRIPTION := OBJECTIVE_DESCRIPTION, @OBJECTIVE_1_LVL := OBJECTIVE_LEVEL, @OBJECTIVE_1_TARGET := OBJECTIVE_COMPETION_COUNT, @REWARD_1_CODE := OBJECTIVE_REWARD , @OBJECTIVE_1_REWARD := REWARD_VALUE, @OBJECTIVE_1_REWARD_TYPE := REWARD_TYPE 
FROM Objectives 
JOIN Objective_Reward_Codes 
ON REWARD_ID = OBJECTIVE_REWARD 
WHERE OBJECTIVE_ID = @OBJECTIVE_1_ID;

SELECT @NEW_OBJECTIVE_1_DESCRIPTION := Objectives.OBJECTIVE_DESCRIPTION, @NEW_OBJECTIVE_1_LVL := Objectives.OBJECTIVE_LEVEL, @NEW_OBJECTIVE_1_TARGET := Objectives.OBJECTIVE_COMPETION_COUNT, @NEW_REWARD_1_CODE := Objectives.OBJECTIVE_REWARD , @NEW_OBJECTIVE_1_REWARD := Objective_Reward_Codes.REWARD_VALUE, @NEW_OBJECTIVE_1_REWARD_TYPE := Objective_Reward_Codes.REWARD_TYPE 
FROM Objectives 
JOIN Objective_Reward_Codes 
ON Objective_Reward_Codes.REWARD_ID = Objectives.OBJECTIVE_REWARD 
WHERE OBJECTIVE_ID = @NEW_OBJECTIVE_1_ID;
DELIMITER ;

是否可能是由Tomcat版本或JDBC发送的查询编码引起的?

0 个答案:

没有答案