这里,很简单,例如我如何使用 callablestatement
Connection con = getConnection();
CallableStatement call = con.prepareCall("{call SpName(?, ?)}");
call .setObject(1, params[0]);
call .setObject(2, params[1]);
call .execute();
ResultSet rs = call .getResultSet();
它对所有 SP 都运行良好。 但如果 SP 中使用了临时表,则返回 null 结果集。
最佳答案
通过添加此代码解决了我的问题
while (true) {
rs = cstmt.getResultSet();
int updateCount = cstmt.getUpdateCount();
LogWriter.write(" Update count " + updateCount);
if (rs == null && updateCount == -1) {
break;
}
if (rs != null) {
// process the result set
} else {
System.out.println("Update count = " + cstmt.getUpdateCount());
}
cstmt.getMoreResults();
}
引用:Here
关于java - 如果在 SP 中使用临时表,则 JDBC 可调用语句返回 null 结果集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39524932/