0
public class TestProcedure extends StoredProcedure {
TestProcedure(BasicDataSource dataSource, String procName) {
this.setDataSource(dataSource);
this.setSql(procName);
this.declareParameter(new SqlParameter("@test", Types.INTEGER));
}
public List<Detail> executeProcedure(Integer studentId) {
Map inParams = new HashMap();
inParams.put("@test", studentId);
this.compile();
List<Detail> details = new ArrayList<Detail>();
try {
ArrayList<LinkedHashMap<String, Object>> list = (ArrayList<LinkedHashMap<String, Object>>) execute(inParams).get("#result-set-1");
for (LinkedHashMap<String, Object> linkedHashMap : list) {
Detail detail = new Detail();
detail.setStudent_id((Integer) linkedHashMap.get("student_id"));
detail.setStudent_name((String) linkedHashMap.get("student_name"));
detail.setStudent_marks((Double) linkedHashMap.get("student_marks"));
details.add(detail);
}
} catch (Exception e) {
System.out.println("Error Man : " + e);
}
return details;
}
以上是通過調用春SP任何人都可以提出一個總體結構爲它。有些抽象類和接口的代碼....