hibernate dao 调用ORACLE存储过程

  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);// 获取输出参数的值   
    }   
 });  
}
请使用浏览器的分享功能分享到微信等