SpringJDBC 给出 ORA-00933:SQL 命令未正确结束但查询在 DB 客户端中运行正常

SpringJDBC Gives ORA-00933: SQL command not properly ended But Query Runs OK in DB Client

以下 Oracle 查询在我的数据库客户端、PL/SQL 开发人员和 returns 1 个结果中运行正常。

在 运行 上,通过我的 Java 应用程序中的 NamedParameterJdbcTemplate (SpringJDBC),我得到

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

不可能有任何 space 问题或任何明显的问题,因为这个确切的查询在 PL/SQL 中完成。

private static final String SELECT1 = 
        " SELECT COUNT(*) " 
        " FROM table1 t1, table2 t2 " + 
        " WHERE t1.received_date > TRUNC(sysdate - 1) " + 
        " AND t1.received_date < TRUNC(sysdate) " + 
        " AND t1.type IN ('TYPE1', 'TYPE2') " + 
        " AND t2.received_num = t1.received_num; ";

public int getSelect1() {

    HashMap<String,Object> paramMap = new HashMap<String,Object>();     
    return jdbcTemplate.queryForObject(SELECT1, paramMap, Integer.class);       
}   

我认为 sql 字符串不需要分号。

private static final String SELECT1 = 
        " SELECT COUNT(*) " +
        " FROM table1 t1, table2 t2 " + 
        " WHERE t1.received_date > TRUNC(sysdate - 1) " + 
        " AND t1.received_date < TRUNC(sysdate) " + 
        " AND t1.type IN ('TYPE1', 'TYPE2') " + 
        " AND t2.received_num = t1.received_num ";