1. spring jdbc call oralce procedure:
final String callFunctionSql = "{call SP_Test(?,?,?)}"; List<SqlParameter> params = new ArrayList<SqlParameter>(); params.add(new SqlParameter(Types.INTEGER)); params.add(new SqlReturnResultSet("result", new ResultSetExtractor<Integer>() { @Override public Integer extractData(ResultSet rs) throws SQLException,DataAccessException { while(rs.next()) { return rs.getInt(1); } return 0; }})); Map<String,Object> map = getJdbcTemplate().call(new CallableStatementCreator() { @Override public CallableStatement createCallableStatement(Connection conn) throws SQLException { CallableStatement cstmt = conn.prepareCall(callFunctionSql); cstmt.setInt(1, 2); cstmt.setInt(2, 16); cstmt.setInt(3, 10); return cstmt; } }, params);
2.Spring jdbc call oracle function
String i = getJdbcTemplate().execute("{?=call FN_UPDATE_BUSINESS_UNIT(?,?,?)}", new CallableStatementCallback<String>() { public String doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException { cs.registerOutParameter(1, java.sql.Types.VARCHAR); cs.setInt(2, 2); cs.setInt(3, 16); cs.setInt(4, 8); cs.execute(); return cs.getString(1); } });