JDBC调用Sybase存储过程,结果集总是无法返回!
java代码部分如下:
String sproc = "{ call zhouxiaobotest2(?,?,?,?)} ";
CommonDAO dao = null;
try {
dao = new CommonDAO(jndi);
Connection connect = dao.getConn();
//得到总数
rowNum = PageDiv.getCount(countSql.toString(), dao);
//设置分页信息
pageBean.setPageInfo(rowNum, pageSize);
// 获取CallableStatement语句:
CallableStatement mStatement = connect.prepareCall(sproc,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
// 传入输入参数和注册输出参数
mStatement.setString(1,sql.toString());
mStatement.setInt(2, 10);
mStatement.setInt(3, 10);
mStatement.setInt(4, 5000);
// 执行存储过程
ResultSet rs = null;
mStatement.execute();
rs = mStatement.getResultSet();
catch (Exception ex) {
ex.printStackTrace();
logger.warn(sql.toString());
} finally {
dao.destroy();
dao = null;
sproc = null;
}
存储过程如下:
create procedure zhouxiaobotest @qry varchar(16384),@ipage int, @num int,@maxpages int
as
/*@qry SQL语句, @ipage 页数, @num 每页记录条数, @maxpages 最大查询页数 */
begin
declare @execsql varchar(16384)
set @execsql = " select USER_NAME from TBL_USER "
execute (@execsql)
end
create procedure zhouxiaobotest2 @qry varchar(16384),@ipage int, @num int,@maxpages int
as
/*@qry SQL语句, @ipage 页数, @num 每页记录条数, @maxpages 最大查询页数 */
begin
select USER_NAME from TBL_USER
end
现在我的问题是调用存储过程zhouxiaobotest,mStatement.execute()始终是fal