我在jdbctemplate中得到java.lang.NullPointerException
。
public List getWorkListLogData(int workListId) {
System.out.println(workListId);
String sql = "SELECT TENDERNO FROM eps.WORKLISTMMDETAIL_LOG WHERE WORKLISTID=?";
List<WorkListDataLogForm> getWorkListData = new ArrayList<WorkListDataLogForm>() ;
try{
SqlRowSet rowset=getJdbcTemplate().queryForRowSet(sql,new Object[]{workListId});
WorkListDataLogForm form =null;
if(rowset!=null)
{
while(rowset.next())
{
form = new WorkListDataLogForm();
form.setTenderId(rowset.getString(1));
getWorkListData.add(form);
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
return getWorkListData;
}
我希望它会返回一些值,但是会抛出空指针异常。 workListId打印正常,但在这一行中我出错了。
SqlRowSet rowset=getJdbcTemplate().queryForRowSet(sql,new Object[]{workListId});
getJdbcTemplate()
是JdbcDaoSupport
类中的内置方法,堆栈跟踪为
6/19/19 11:02:55:112 IST] 00000011 SystemErr R java.lang.NullPointerException [6/19/19 11:02:55:114 IST] 00000011 SystemErr R at com.mj.eps.business.datacenter.data.JdbcCommonRepository.getWorkListLogData(JdbcCommonRepository.java:278) [6/19/19 11:02:55:114 IST] 00000011 SystemErr R at mj.eps.action.business.automation.sda.WorkListDataLogAction.execute(WorkListDataLogAction.java:34) [6/19/19 11:02:55:115 IST] 00000011 SystemErr R at