调用存储过程输出参数

时间:2018-06-05 19:14:33

标签: sql stored-procedures jdbc cloudera

函数符号返回-1,0或1,具体取决于变量testVal的符号,但输出参数未被识别:

    static int callableStatement(Connection con, double testVal)
        throws SQLException {
     CallableStatement cstmt = con.prepareCall("{ ? = Select sign(?)}");
     cstmt.registerOutParameter(1, Types.INTEGER);
     cstmt.setDouble(2, testVal);
     cstmt.executeQuery();
     int sign = cstmt.getInt(1);
     System.out.println(sign);
     return sign;
      }

stacktrace给出了SQL错误:

    java.sql.SQLException: [Cloudera][JDBC](11420) Error, parameter metadata 
    not populated.

0 个答案:

没有答案