org.h2.jdbc.JdbcSQLException:SQL语句中的语法错误“?= CALL PKG_DATA_INGESTION.F_GET_CONFIGURATION_COMPONENTS([*] ?,?)”;

时间:2019-11-21 07:18:47

标签: java h2

我为包名称创建了别名:

CREATE ALIAS IF NOT EXISTS PKG_DATA_INGESTION.F_GET_CONFIGURATION_COMPONENTS FOR
"com.db.aminet.cucumbertests.Orchestrator.H2databaseProc.selectComponentsConfig";

给定包的java类:

public class H2databaseProc {

    public static ResultSet selectComponentsConfig(final String componentConfig, final Date executionDate) throws SQLException {
        String h2Pwd=EncrypterFactory.getEncrypter().decrypt("ENC(bZO5WqcDhckxAFZhcZD5+6g3vbMMOZuwTHmtNKuIhBe4+oFdaDwintZvbNqDQYGj)");
        Connection conn = DriverManager.getConnection("jdbc:h2:mem:test", "sa", h2Pwd);
        PreparedStatement controlComponent = conn.prepareStatement("select PROPERTY_KEY, PROPERTY_VALUE from component_config where COMPONENT_ID = ? and INIT_DATE <= TO_DATE(?, 'YYYY-MM-DD') and (END_DATE is NULL OR END_DATE >= TO_DATE(?, 'YYYY-MM-DD')) and IS_LIST = 0; ");
        controlComponent.setString(1, componentConfig);
        controlComponent.setDate(2, executionDate);
        ResultSet rs = controlComponent.executeQuery();
        return rs;
    }
}

在java中调用包:

conn = DriverManager.getConnection(this.jdbcUrlDB, this.usernameDB, this.passwordDB);
            cstmt = conn.prepareCall("{? = call PKG_DATA_INGESTION.F_GET_CONFIGURATION_COMPONENTS(?, ?)}");
            cstmt.registerOutParameter(1, -10);
            cstmt.setString(2, this.componentID);
            cstmt.setDate(3, new java.sql.Date(this.date.getTime()));
            cstmt.execute();

我遇到错误:

org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement " ? = CALL PKG_DATA_INGESTION.F_GET_CONFIGURATION_COMPONENTS([*]?, ?)  "; SQL statement:
 ? = call PKG_DATA_INGESTION.F_GET_CONFIGURATION_COMPONENTS(?, ?)  [42000-176]

    at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)

0 个答案:

没有答案