[英]JDBC: check stored procedure return value
I have a stored procedure on my postgresql database that return integer value. 我的PostgreSQL数据库上有一个存储过程,该存储过程返回整数值。 When i call my procedure form jdbc client using CallableStatement, when i call execute() method on CallableStatement object, it returns only a boolean.
当我使用CallableStatement调用过程形式的jdbc客户端程序时,当我对CallableStatement对象调用execute()方法时,它仅返回一个布尔值。 How can i read the effective return value of function?
如何读取函数的有效返回值?
You need to get a ResultSet via: 您需要通过以下方式获取ResultSet:
ResultSet rs = stmt.executeQuery("SELECT * FROM setoffunc()");
while (rs.next()) {
// read results
}
rs.close();
stmt.close();
Or: 要么:
// Procedure call.
CallableStatement proc = conn.prepareCall("{ ? = call refcursorfunc() }");
proc.registerOutParameter(1, Types.OTHER);
proc.execute();
ResultSet results = (ResultSet) proc.getObject(1);
while (results.next()) {
// read results
}
results.close();
proc.close();
See the documentation for more details: http://jdbc.postgresql.org/documentation/80/callproc.html 有关更多详细信息,请参见文档: http : //jdbc.postgresql.org/documentation/80/callproc.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.