[Oracle]JDBCTemplate调用Oracle存储过程示例
[Oracle]JDBCTemplate调用Oracle存储过程示例
this.getJdbcTemplate().execute(
new CallableStatementCreator() {
public CallableStatement createCallableStatement(Connection con) throws SQLException {
String storedProc = "{call updatetractractcode(?, ?)}";// 调用的存储过程
CallableStatement cs = con.prepareCall(storedProc);
cs.setInt(1, contractId);// 设置输入参数的值
cs.registerOutParameter(2, java.sql.Types.INTEGER);// 注册输出参数的类型
return cs;
}
}, new CallableStatementCallback() {
public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
cs.execute();
return cs.getString(2);// 获取输出参数的值
}
});