我想通过使用jmeter来测试Oracle存储过程。我已经完成了除参数以外的所有操作。如何使用jmeter使用sys_refcursor返回类型来测试Oracle存储过程?
这里是我的SQL查询:
声明 outinfo VARCHAR2(20); outtable sys_refcursor; begin {call RK_JSCX(?,?)}; 结束;
Oracle中的outtable是一个cursor.And我使用了resultSet来包含它在java.However,无论我在参数类型中设置,它说无效类型。
采样开始:2012年10月25日16时06分41秒CST 装载时间:0 延迟:0 字节大小:25 头大小的字节数:0 字节车身尺寸:25 样品数:1个 错误计数:1个 响应代码:空0 响应消息:值java.sql.SQLException:无效数据类型:光标
响应头: [email protected]
个SampleResult领域: 的ContentType:text/plain的 DataEncoding:UTF-8
如何解决这个问题? 谢谢!
这是我在Java代码:
public String RK_JSCX() throws Exception {
RK_JSCX_Response response = null;
List<RK_JSCX_Outtable> list = null;
Connection con = null;
CallableStatement cs = null;
ResultSet rs = null;
String sql = null;
try {
sql = "{call RK_JSCX(?,?)}";
con = ConnectionUtils.getInstance().getConnect();
if (con.isClosed()) {
throw new IllegalStateException("ERROR.THE CONNECTION ISCLOSED");
}
cs = con.prepareCall(sql);
cs.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR);
cs.registerOutParameter(2, Types.VARCHAR);
cs.execute();
rs = (ResultSet) cs.getObject(1);
list = new ArrayList<RK_JSCX_Outtable>();
while (rs.next()) {
RK_JSCX_Outtable out = new RK_JSCX_Outtable(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getInt(5), rs.getString(6));
list.add(out);
}
String outInfo = cs.getString(2);
response = new RK_JSCX_Response(list, outInfo);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
if (rs != null) {
rs.close();
if (cs != null) {
cs.close();
}
if (con != null) {
con.close();
}
}
} catch (SQLException e) {
System.out.println("Exception2");
e.printStackTrace();
}
}
return JSON.toJSONString(response);
}
您可以发布您的代码,你在呼唤你的Oracle从Java存储过程? – user75ponic
是的,我已经添加了我的代码。 – luting
所以你在这里得到异常'cs = con.prepareCall(sql); cs.registerOutParameter(1,oracle.jdbc.OracleTypes.CURSOR); cs.registerOutParameter(2,Types.VARCHAR);'你的程序收到一个正确的参数? – user75ponic