日期:2014-05-17 浏览次数:20730 次
cstmt = conn.prepareCall("begin test(?,?); end;");
cstmt.setInt(1, deptno);
cstmt.registerOutParameter(2, OracleTypes.CURSOR);
cstmt.execute();
rs = (ResultSet) cstmt.getObject(2);
ResultSetMetaData rsm = rs.getMetaData();
int columnCount = rsm.getColumnCount();
while (rs.next()){
for (int j=0;j< columnCount;j++){
temp = rs.getObject(j+1);
}
}
callableStatement = connection.prepareCall("{ call zhangbo.pro_input_output(?,?) }");
callableStatement.setInt(1, 7521);//输入参数
callableStatement.registerOutParameter(2, Types.VARCHAR);//输出参数
callableStatement.execute();//执行存储过程
String name = callableStatement.getString(2);//获取输出参数
System.out.println("编号7521的员工姓名为: " + name);
SELECT 'Return Value' = @answer
prepareStatement("{call xxxx(?)}");
stmt.setString(1, customerId);
rs = stmt.executeQuery();
if (rs.next()) {
rs.getString("Return Value");
}