存储过程使用:
//执行项目编号 调用存储过程
Map map=new HashMap();
String sql="{?=call pr_ys_bz(?,?,?)}";
map.put("2", "");
map.put("3", ztbModel.getXdnd());
map.put("4", ztbModel.getXdpc());
String str = proxyService.getSqlprocedureService().excutSqlproc2(sql, map);
调用存储过程,并传值:
public String excutSqlproc2(String sql,Map map) throws Exception{
Connection db_conn=this.proxyDao.getBasicdataDao().getSession().connection();
CallableStatement sqlstmt=db_conn.prepareCall(sql);
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object val = entry.getValue();
sqlstmt.setString(Integer.parseInt((String) key), (String) val);
}
sqlstmt.registerOutParameter(1,java.sql.Types.INTEGER);//注册输出参数
sqlstmt.registerOutParameter(2,java.sql.Types.VARCHAR);//注册输出参数
sqlstmt.executeUpdate();
String str=sqlstmt.getString(2);
return str;
}