By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,795 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,795 IT Pros & Developers. It's quick & easy.

Null field . I got this error : java.lang.NullPointerException

P: 11
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.
May 24 '10 #1
Share this Question
Share on Google+
3 Replies


ThatThatGuy
Expert 100+
P: 449
Posting Such huge chunk of code. will not help
post only the portion of the code that's creating the problem.
May 24 '10 #2

jkmyoung
Expert 100+
P: 2,057
Could you indicate the line in updateXC18() where you are getting the null exception?

Side comments: I don't get why you're constantly using: file_no=xcbo.getFileNo();
and expecting to get different results. But then again we have no idea what your XC18BO class looks like.
May 25 '10 #3

P: 11
hi young, thanks for the comment...
it seems that that lines was the problem...
things went well after I uncomment the next lines of

'if (file_no==null) file_no=xcbo.getFile_no();'.


Thank u anyway.....
May 26 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.