一:参考网址
http://sunbin123.iteye.com/blog/1007556
二:示例
@Autowired @Qualifier("jdbcTemplate") private JdbcTemplate jdbcTemplate; @SuppressWarnings("unchecked") public Integer GetSerNo() { Integer param2Value = jdbcTemplate.execute( new CallableStatementCreator() { public CallableStatement createCallableStatement(Connection con) throws SQLException { String storedProc = "{call getSNo(?,?)}";// 调用的sql CallableStatement cs = con.prepareCall(storedProc); cs.setString(1, sno);// 设置输入参数的值 cs.registerOutParameter(2, java.sql.Types.INTEGER); return cs; } }, new CallableStatementCallback() { public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException { cs.execute(); return cs.getInt(2);// 获取输出参数的值 } }); return param2Value; }
时间: 2024-10-10 13:49:54