Sql 调用存储过程输出参数
函数符号根据变量testVal的符号返回-1、0或1,但无法识别输出参数:Sql 调用存储过程输出参数,sql,stored-procedures,jdbc,cloudera,Sql,Stored Procedures,Jdbc,Cloudera,函数符号根据变量testVal的符号返回-1、0或1,但无法识别输出参数: static int callableStatement(Connection con, double testVal) throws SQLException { CallableStatement cstmt = con.prepareCall("{ ? = Select sign(?)}"); cstmt.registerOutParameter(1, Types.INT
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.
什么是
testVal
?您是否尝试过使用CallableStatement cstmt=con.prepareCall(“{?=callsign(?)”)
和cstmt.registerOutParameter(1,Types.INTEGER)代码>?我尝试将testVal=-20作为int和double,以防不支持自动转换。当运行CallableStatement cstmt=con.prepareCall(“{?=Select sign(?)}”);cstmt.registerOutParameter(1,Types.INTEGER);我得到了与上述相同的错误。您能添加一个最小的、可验证的和完整的示例吗?更新了原始问题关于“{?=呼号(?)}
而不是选择?