使用 Rational Application Developer V7.5 版本来进行资源注入
2010-08-06 00:00:00 来源:WEB开发网从代码行 5 添加 callInoutParameter(con, outMedian)方法,可以从 SpClient.java 程序中直接得到它。
清单 5. SpClient 存储的程序访问
private void callInoutParameter(Connection con, double median) {
try {
// prepare the CALL statement for INOUT_PARAM
String procName = "INOUT_PARAM";
String sql = "CALL James." + procName + "(?)";
CallableStatement callStmt = con.prepareCall(sql);
// set input parameter to median value passed back by OUT_PARAM
callStmt.setDouble(1, median);
// register the output parameters
callStmt.registerOutParameter(1, Types.DOUBLE);
if (median == 99999.99) {
System.out.println("-- The following error is expected! --");
}
callStmt.execute();
// retrieve output parameters
double inoutMedian = callStmt.getDouble(1);
System.out.println(procName + " completed successfully");
System.out.println("Median salary returned from " + procName
+ " = " + inoutMedian);
// clean up resources
callStmt.close();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
Tags:使用 Rational Application
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接