hibernate dao 调用ORACLE存储过程
String param2Value = (String) jdbcTemplate.execute(
new CallableStatementCreator() {
public CallableStatement createCallableStatement(Connection con) throws SQLException {
String storedProc = " call sp_update_task_assignee(?,?,?,?) ";// 调用的sql
CallableStatement cs = con.prepareCall(storedProc);
cs.setString(1, instanceid);// 设置输入参数的值
cs.setString(2, assignee);// 设置输入参数的值
cs.setString(3, username);// 设置输入参数的值
cs.registerOutParameter(4, OracleTypes.VARCHAR);// 注册输出参数的类型
return cs;
}
}, new CallableStatementCallback() {
public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
cs.execute();
return cs.getString(4);// 获取输出参数的值
}
});
}
String param2Value = (String) jdbcTemplate.execute(
new CallableStatementCreator() {
public CallableStatement createCallableStatement(Connection con) throws SQLException {
String storedProc = " call sp_update_task_assignee(?,?,?,?) ";// 调用的sql
CallableStatement cs = con.prepareCall(storedProc);
cs.setString(1, instanceid);// 设置输入参数的值
cs.setString(2, assignee);// 设置输入参数的值
cs.setString(3, username);// 设置输入参数的值
cs.registerOutParameter(4, OracleTypes.VARCHAR);// 注册输出参数的类型
return cs;
}
}, new CallableStatementCallback() {
public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
cs.execute();
return cs.getString(4);// 获取输出参数的值
}
});
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26495863/viewspace-1395513/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26495863/viewspace-1395513/