java调用Oracle过程或则函数返回结果集

import javax.sql.rowset.CachedRowSet;
import com.sun.rowset.CachedRowSetImpl;
/*
................
...........
.....
*/
Connection con = null;
java.sql.Statement  st = null;
java.sql.ResultSet  rs = null;

try {
	// 通过JNDI获得数据库连接
	String driverClass = this.getServlet().getServletConfig()
			.getInitParameter("driverClass");
	String jdbcUrl = this.getServlet().getServletConfig()
			.getInitParameter("jdbcUrl");
	String user = this.getServlet().getServletConfig()
			.getInitParameter("user");
	String password = this.getServlet().getServletConfig()
			.getInitParameter("password"); 

	con = DriverManager.getConnection(jdbcUrl, user, password);
 
	CallableStatement cstmt= null;;
	sql = "{? = call pkg_money_check.get_factor_CUR(?,?,?,?,?,?)}"; 
	cstmt = con.prepareCall(sql); 

	cstmt.registerOutParameter(1,oracle.jdbc.OracleTypes.CURSOR);
	cstmt.setString(2,MONTH_ID);
	cstmt.setString(3,AGENT_AREA);
	cstmt.setString(4,ruleId);
	cstmt.setString(5,userInfo.getUserID());
	cstmt.setString(6,sessionID);
	cstmt.setString(7,IP);
	cstmt.execute();
	
	System.out
		.println("call pkg_money_check.get_factor_CUR('"
				+ MONTH_ID
				+ "','"
				+ AGENT_AREA
				+ "','"
				+ ruleId
				+ "','"
				+ userInfo.getUserID()
				+ "','"
				+ sessionID 
				+ "','"
				+ IP
				+ "')");
	
	rs = (ResultSet) cstmt.getObject(1);
	CachedRowSet crs = new CachedRowSetImpl();
	crs.populate(rs);
	ds = dc.convertRsToDs(crs);


} catch (Exception e) {
	e.printStackTrace();
} finally {
	con.commit();
	if (rs != null) {
		rs.close();
		rs = null;
	}
	if (st != null) {
		st.close();
		st = null;
	}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值