i am calling a function from controller class. function is defined in another class function. but before executing return code it gives error. (as debugging) it jumps from the line modelMap.put("list", arraylist); it gives exception, nullpointerexception.
controller.java
@RequestMapping(value = "/index.htm")
public String getData() throws ClassNotFoundException {
function obj = new function();
ModelMap modelMap = null;
obj.getdata(modelMap);
return "index";
}
function.java
public ModelMap getdata(ModelMap modelMap) throws ClassNotFoundException {
SqlRowSet srs = null;
ArrayList arraylist = new ArrayList();
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
dataSource = new connection.connection().getConnection(dataSource);
JdbcTemplate get = new JdbcTemplate(dataSource);
//Operation
String sql = "SELECT * FROM user_info";
srs = get.queryForRowSet(sql);
while (srs.next()) {
pojo obj = new pojo();
obj.setEmail_id(srs.getString("email_id"));
obj.setPassword(srs.getString("pwd"));
arraylist.add(obj);
}
modelMap.put("list", arraylist);
return modelMap;
}