Hello guys...
Data is not updated into table. I got this error : java.lang.NullPointerException
[5/24/10 10:11:24:012 SGT] 00000030 SystemErr R java.lang.NullPointerException
[5/24/10 10:11:24:028 SGT] 00000030 SystemErr R at my.org.hasil.dcms.grq.dao.XC18DAO.updateXC18(XC18D AO.java)
[5/24/10 10:11:24:028 SGT] 00000030 SystemErr R at my.org.hasil.dcms.grq.bo.XC18BO.processXC18(XC18BO .java)
[5/24/10 10:11:24:028 SGT] 00000030 SystemErr R at my.org.hasil.dcms.grq.web.XC18Action.performSedia( XC18Action.java)
The program :
1.)my.org.hasil.dcms.grq.web.XC18Action.performSed ia(XC18Action.java)
public ActionForward performSedia(
ActionMapping mapping,
ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
{
ActionForward forward=new ActionForward();
HttpSession httpSession = request.getSession();
MESSession session = (MESSession) httpSession.getAttribute(DCMSConstants.DCMSConstan ts_MESSESSION);
TodoparameterForm todoForm=(TodoparameterForm)httpSession.getAttribu te("todoparamForm");
XC18BO xcbo=new XC18BO(session);
XC18Form xc18form=(XC18Form)form;
try
{
BeanUtils.copyProperties(xcbo,todoForm);
BeanUtils.copyProperties(xcbo,xc18form);
xcbo.setTodo_id(xc18form.getId());
xcbo.setStatus(DCMSConstants.USERTODO_STATUS_SEDIA );
xcbo.processXC18(); }catch(Exception e)
{
e.printStackTrace();
}
forward=mapping.findForward("success");
return forward;
}
2.)my.org.hasil.dcms.grq.bo.XC18BO.processXC18(XC1 8BO.java)
public void processXC18()
{
try{
setDaoName("my.org.hasil.dcms.grq.dao.XC18DAO");
requestConnection();
XC18DAO xcDao =(XC18DAO)getDAO();
xcDao.insertUserTodo(this);
XC18DAO xcDao1 =(XC18DAO)getDAO();
xcDao1.updateXC18(this);
commit();
}
3.) XC18BO.java
public void updateXC18(XC18BO xcbo) throws SQLException
{
String file_no=xcbo.getFileNo();
if (file_no==null) file_no=xcbo.getFileNo();
String it_ref_no=xcbo.getIt_ref_no();
int taxpayer_key=xcbo.getTaxpayer_key();
int taxtype_key = Integer.parseInt(xcbo.getTaxtype_key());
String status = xcbo.getStatus();
String update_field = "";
if ( status.equals(DCMSConstants.USERTODO_STATUS_SEDIA)
|| status.equals(DCMSConstants.USERTODO_STATUS_PREPAR E))
{
update_field = new StringBuffer()
.append(" OFFICER_PREPARE = ?, ")
.append(" DATE_PREPARE = ?, ")
.append(" STATUS = ? ")
.toString();
}else if( status.equals(DCMSConstants.USERTODO_STATUS_LULUS) )
{
update_field = new StringBuffer()
.append(" OFFICER_APPROVE = ?, ")
.append(" DATE_APPROVE = ?, ")
.append(" STATUS = ? ")
.toString();
}
else if( status.equals(DCMSConstants.USERTODO_STATUS_TOLAK) )
{
if (file_no==null) file_no=xcbo.getFile_no();
update_field = new StringBuffer()
.append(" OFFICER_REJECT = ?, ")
.append(" DATE_REJECT = ?, ")
.append(" STATUS = ? ")
.toString();
}
else if( status.equals(DCMSConstants.USERTODO_STATUS_XCHEAD _TOLAK))
{
if (file_no==null) file_no=xcbo.getFile_no();
update_field = new StringBuffer()
.append(" OFFICER_REJECT = ?, ")
.append(" DATE_REJECT = ?, ")
.append(" STATUS = ? ")
.toString();
}
else if( status.equals(DCMSConstants.USERTODO_STATUS_TERIMA ))
{
file_no=xcbo.getFile_no();
update_field = new StringBuffer()
.append(" OFFICER_RECEIVED = ?, ")
.append(" DATE_RECEIVED = ?, ")
.append(" STATUS = ? ")
.toString();
}
PreparedStatement stmt = null;
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE " + tableName + " SET ");
sql.append(update_field);
sql.append(" WHERE ");
sql.append(" TAXPAYER_KEY = ?");
sql.append(" AND FILE_NO = ?");
sql.append(" AND TAXTYPE_KEY = ?");
stmt = conn.prepareStatement(sql.toString());
stmt.setString(1, session.getUserBo().getUser_id());
stmt.setTimestamp(2, now());
stmt.setString(3, status);
stmt.setInt(4, taxpayer_key);
stmt.setString(5, file_no);
stmt.setInt(6, taxtype_key);
stmt.executeUpdate();
}
Where did I go wrong? It seems that the field that I need is null. How can I fill up the field with the data? Please...I'm so stucked and lost!
TQ.