標籤:seq commit cat factor oca div lis nbsp try
hibernate:
private String getNewSeq(String eService) {String no = "";Session session = getSessionFactory().openSession();Transaction tx = null;try {tx = session.beginTransaction();CallableStatement call = session.connection().prepareCall("{call PF_genRefNo(?,?)}");call.setString(1, eService);call.registerOutParameter(2, Types.VARCHAR);call.execute();no = call.getString(2);tx.commit();} catch (SQLException e) {log.error(e.getMessage(),e);}finally{if (session != null) { try { session.close(); } catch (HibernateException e) { log.error(e.getMessage(),e); } }}return no;}
mybatits:
public List getLocationOfVesselStatusNS(final Map paraMap){ final List retList = new ArrayList(); final String sql=" {call marinedb_ncs_p2_uat.dbo.p_PTMS_enqVslCurStatusPTMS(?)}"; Map searchMap=(Map)paraMap.get("searchMap"); final int vslId=(Integer)searchMap.get("vslId"); Object object = jdbcTemplate.execute(new CallableStatementCreator() { public CallableStatement createCallableStatement(Connection arg0) throws SQLException { CallableStatement cs = arg0.prepareCall(sql); return cs; } }, new CallableStatementCallback() { public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException { cs.setInt(1, vslId); cs.execute(); List columns = new ArrayList(); columns.add("vsl_x"); columns.add("vslprev_x"); columns.add("vsllstp_x"); columns.add("vslnxp_x"); columns.add("vslcallsign_x"); columns.add("licno_x"); columns.add("vslty_x"); columns.add("vslflag_x"); columns.add("vslgt_x"); columns.add("vsllen_x"); columns.add("vsldeclrarr_x"); columns.add("vsldeclrdep_x"); columns.add("agent_x"); columns.add("mvstm_eta_x"); columns.add("mvetm_eta_x"); columns.add("mvstm_etd_x"); columns.add("mvetm_etd_x"); columns.add("currlocn_x"); columns.add("vslimo_x"); ResultSet rs = cs.getResultSet(); while (rs.next()) { Map map = new HashMap(); for (int i = 0; i < columns.size(); i++) { map.put(columns.get(i), rs.getString(i + 1)); } retList.add(map); } return retList; } }); return retList; }
hibernate和mybatits執行預存程序