基于手工的调用方式
/**
* 得到道路设施ids集
*
* @param sw
* @param ne
* @param center
* @param types
* @return
*/
protected String getRoadFacilityIds(String sw, String ne, String center,
String types) {
String resultFacilityIds = null;
Session session = this.getTemplate().getSessionFactory()
.getCurrentSession();
Transaction tx = null;
CallableStatement cstmt = null;
try {
tx = session.beginTransaction();
@SuppressWarnings("deprecation")
Connection con = session.connection();
String procedure = "{call getroadfaiclities(?,?,?,?,?,?)}";
cstmt = con.prepareCall(procedure);
cstmt.setString(1, center);
cstmt.setString(2, sw);
cstmt.setString(3, ne);
cstmt.setString(4, types);
cstmt.setInt(5, 70);
cstmt.registerOutParameter(5, java.sql.Types.INTEGER);
cstmt.registerOutParameter(6, java.sql.Types.VARCHAR);
cstmt.execute();
resultFacilityIds = cstmt.getString(6);
tx.commit();
} catch (Exception e) {
tx.rollback();
throw new SystemException(e);
} finally {
if (cstmt != null) {
try {
cstmt.close();
} catch (SQLException e) {
tx.rollback();
throw new SystemException(e);
}
}
}
return resultFacilityIds;
}
存储过程如下:
CREATE OR REPLACE PROCEDURE GETROADFAICLITIES(center IN VARCHAR2,
sw IN VARCHAR2,
ne IN VARCHAR2,
facilities IN VARCHAR2,
pointNum IN OUT INTEGER,
facilitiesids OUT VARCHAR2) IS
注意这里的in和out参数类型