gpt4 book ai didi

java - JDBC - java.sql.SQLException : ORA-00933: SQL command not properly ended

转载 作者:行者123 更新时间:2023-12-01 20:19:46 24 4
gpt4 key购买 nike

我试图通过 JDBC 在 Oracle DB 中执行以下查询,但它抛出异常。异常(exception)是:

java.sql.SQLException: ORA-00933: SQL command not properly ended

请建议需要更改哪些内容?

String questionQuery = "SELECT PCN_SURVEY_DEFINITION.ID, PCN_SURVEY_DEFINITION.NAME, PCN_QUESTIONS.ID, PCN_QUESTIONS.SURVEY_ID, PCN_QUESTIONS.LABEL, "
+ "PCN_QUESTIONS.TYPE, PCN_QUESTIONS.REQUIRED, PCN_QUESTIONS.COMMENTS, PCN_QUESTIONS.DISPLAY_ORDER "
+ "FROM PCN_SURVEY_DEFINITION, PCN_QUESTIONS "
+ "WHERE PCN_SURVEY_DEFINITION.ID = PCN_QUESTIONS.SURVEY_ID "
+ "AND PCN_SURVEY_DEFINITION.NAME=? "
+ "ORDER BY PCN_QUESTIONS.DISPLAY_ORDER ASC";

最佳答案

更正 WHERE 子句中的条件并正确检查引号 (") 的起始位置和结束位置。

"WHERE PCN_SURVEY_DEFINITION.ID = " + PCN_QUESTIONS.SURVEY_ID + " AND PCN_SURVEY_DEFINITION.NAME=? " + "ORDER BY PCN_QUESTIONS.DISPLAY_ORDER ASC";

关于java - JDBC - java.sql.SQLException : ORA-00933: SQL command not properly ended,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45111550/

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