I am fresher in spring framework and have a very small questions
public Map<Integer,String> getSubXYZ(final Integer reasonId){
final Map<Integer, String> subReasonsMap =
new HashMap<Integer, String>();
final List<BatchPropertyVO> batchPropertyVOList = new ArrayList<BatchPropertyVO>();
PreparedStatementCreator psc = new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection conn) throws SQLException {
String query = SQL_GET_SUBXYZ;
PreparedStatement stmt = conn.prepareStatement(query);
stmt.setInt(1, reasonId);
return stmt;
}
};
jdbcTemplate.query(psc,
new ResultSetExtractor() {
public Object extractData(ResultSet rs) throws SQLException,
DataAccessException {
while (rs.next()) {
subReasonsMap.put( rs.getInt("reason_id"),
rs.getString("reason"));
}
return null;
}
});
return subReasonsMap;
}
Question1: why do we need to use final variable as parameter? when we can change the value of final variable by making it Map ?
Question2: In JdbcTemplate we are using innerclasses and looks little complicated instead using java Jdbc looks simple , I have not read performance of JdbcTemplate over Jdbc so if someOne can provide me good tutorial, I would be very thankful.
Question3: if we have to return simple String or Integer from method we can't as we have declare final variable .
it looks burdensome for code. But to maintain consistency I have to either use JdbcTemplate for all method of dao or java JDBC. Pls help me if some solution is there?
Question 4: if I am not opening connection why it sometime give me exception "close connection"?


Reply With Quote
. If you are using Java 1.5 you might also want to check this out.