views:

13

answers:

1
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;
}

}

Above is the code for calling SP through Spring Can anyone suggest a general structure for it .Some abstract class or interface ....