sql server存储过程返回的游标/记录集 怎么在java里面转成jdbc的啊? oracle的我会转,下面是oracle的:
call.setInt(1,paginationBean.getPageIndex());call.setInt(2,paginationBean.getPageSize...
call.setInt(1,paginationBean.getPageIndex());
call.setInt(2,paginationBean.getPageSize());
call.setString(3,paginationBean.getSql());
call.registerOutParameter(4, java.sql.Types.DECIMAL);
call.registerOutParameter(5, OracleTypes.CURSOR);//OracleTypes.CURSOR就是oracle的,那么sql serverl怎么写呢?
call.registerOutParameter(6, java.sql.Types.DECIMAL);
call.executeQuery();
rs=(ResultSet)call.getObject(5); 展开
call.setInt(2,paginationBean.getPageSize());
call.setString(3,paginationBean.getSql());
call.registerOutParameter(4, java.sql.Types.DECIMAL);
call.registerOutParameter(5, OracleTypes.CURSOR);//OracleTypes.CURSOR就是oracle的,那么sql serverl怎么写呢?
call.registerOutParameter(6, java.sql.Types.DECIMAL);
call.executeQuery();
rs=(ResultSet)call.getObject(5); 展开
1个回答
2016-05-25
展开全部
import oracle.jdbc.*;
...
CallableStatement cstmt;
ResultSet cursor;
// Use a PL/SQL block to open the cursor
//Additional Oracle Type Extensions
cstmt = conn.prepareCall
("begin open ? for select ename from emp; end;";
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.execute();
cursor = ((OracleCallableStatement)cstmt).getCursor(1);
// Use the cursor like a normal ResultSet
while (cursor.next ())
{System.out.println (cursor.getString(1));}
...
CallableStatement cstmt;
ResultSet cursor;
// Use a PL/SQL block to open the cursor
//Additional Oracle Type Extensions
cstmt = conn.prepareCall
("begin open ? for select ename from emp; end;";
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.execute();
cursor = ((OracleCallableStatement)cstmt).getCursor(1);
// Use the cursor like a normal ResultSet
while (cursor.next ())
{System.out.println (cursor.getString(1));}
追问
谢谢你回答,可是你这还是oracle的啊,cstmt.registerOutParameter(1, OracleTypes.CURSOR);这句话就是oracle的,
我要sql server的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询