gpt4 book ai didi

java.sql.SQLException : ORA-00933: SQL command not properly ended Error with LIKE Sql Query 异常

转载 作者:行者123 更新时间:2023-11-30 08:36:48 25 4
gpt4 key购买 nike

我正在使用 jdbc。我收到以下准备语句的异常

  PreparedStatement pstmt=con.prepareStatement("select * from customer where INITIALIZED=1 && FILE_NAME LIKE ?");
//filename is string
pstmt.setString(1, "%" + filename + "%");
rs=pstmt.executeQuery();

我收到以下错误

  016-06-01 18:59:55 ERROR DatabaseUtils:276 - java.sql.SQLException: ORA-00933: SQL command not properly ended

Exception in thread "main" java.lang.NullPointerException
at pe.entel.DatabaseInsertionandRetrieving.LocalDatabaseTransactImpl.retrievewithfilename(LocalDatabaseTransactImpl.java:279)
at pe.entel.DatabaseInsertionandRetrieving.LocalDatabaseTransactImpl.main(LocalDatabaseTransactImpl.java:287)

最佳答案

问题是您的查询有语法错误。在 SQL 中,您需要使用 AND 而不是 &&,如下所示:

// Introduced sql only for a better reading
String sql = "select * from customer where INITIALIZED=1 AND FILE_NAME LIKE ?";
PreparedStatement pstmt = con.prepareStatement(sql);

关于java.sql.SQLException : ORA-00933: SQL command not properly ended Error with LIKE Sql Query 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37570302/

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