前提是加载资源DataSource
private JdbcTemplate jdbcTemplate;
Java 调用存储过程:
@Override
public String oneUniscInfoHisToDm(final String uniscInfoHisId) {
jdbcTemplate = new JdbcTemplate(getDataSource());
String result = (String) jdbcTemplate.execute(
new CallableStatementCreator() {
public CallableStatement createCallableStatement(Connection con) throws SQLException {
String storedProc = "{call unisc_his_to_unisc_info_new (?,?)}";// 调用的sql
CallableStatement cs = con.prepareCall(storedProc);
cs.setString(1, uniscInfoHisId);// 设置输入参数的值
cs.registerOutParameter(2,OracleTypes.INTEGER);// 注册输出参数的类型
return cs;
}
}, new CallableStatementCallback<Object>() {
public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
cs.execute();
return cs.getString(2);// 获取输出参数的值
}
});
return result;
}
原文:http://blog.csdn.net/zjw10wei321/article/details/44151751