Hello guys...
Data is not updated into table. I got this error : java.lang.NullP ointerException
[5/24/10 10:11:24:012 SGT] 00000030 SystemErr R java.lang.NullP ointerException
[5/24/10 10:11:24:028 SGT] 00000030 SystemErr R at my.org.hasil.dc ms.grq.dao.XC18 DAO.updateXC18( XC18DAO.java)
[5/24/10 10:11:24:028 SGT] 00000030 SystemErr R at my.org.hasil.dc ms.grq.bo.XC18B O.processXC18(X C18BO.java)
[5/24/10 10:11:24:028 SGT] 00000030 SystemErr R at my.org.hasil.dc ms.grq.web.XC18 Action.performS edia(XC18Action .java)
The program :
1.)my.org.hasil .dcms.grq.web.X C18Action.perfo rmSedia(XC18Act ion.java)
public ActionForward performSedia(
ActionMapping mapping,
ActionForm form,
javax.servlet.h ttp.HttpServlet Request request,
javax.servlet.h ttp.HttpServlet Response response)
{
ActionForward forward=new ActionForward() ;
HttpSession httpSession = request.getSess ion();
MESSession session = (MESSession) httpSession.get Attribute(DCMSC onstants.DCMSCo nstants_MESSESS ION);
TodoparameterFo rm todoForm=(Todop arameterForm)ht tpSession.getAt tribute("todopa ramForm");
XC18BO xcbo=new XC18BO(session) ;
XC18Form xc18form=(XC18F orm)form;
try
{
BeanUtils.copyP roperties(xcbo, todoForm);
BeanUtils.copyP roperties(xcbo, xc18form);
xcbo.setTodo_id (xc18form.getId ());
xcbo.setStatus( DCMSConstants.U SERTODO_STATUS_ SEDIA);
xcbo.processXC1 8(); }catch(Exceptio n e)
{
e.printStackTra ce();
}
forward=mapping .findForward("s uccess");
return forward;
}
2.)my.org.hasil .dcms.grq.bo.XC 18BO.processXC1 8(XC18BO.java)
public void processXC18()
{
try{
setDaoName("my. org.hasil.dcms. grq.dao.XC18DAO ");
requestConnecti on();
XC18DAO xcDao =(XC18DAO)getDA O();
xcDao.insertUse rTodo(this);
XC18DAO xcDao1 =(XC18DAO)getDA O();
xcDao1.updateXC 18(this);
commit();
}
3.) XC18BO.java
public void updateXC18(XC18 BO xcbo) throws SQLException
{
String file_no=xcbo.ge tFileNo();
if (file_no==null) file_no=xcbo.ge tFileNo();
String it_ref_no=xcbo. getIt_ref_no();
int taxpayer_key=xc bo.getTaxpayer_ key();
int taxtype_key = Integer.parseIn t(xcbo.getTaxty pe_key());
String status = xcbo.getStatus( );
String update_field = "";
if ( status.equals(D CMSConstants.US ERTODO_STATUS_S EDIA)
|| status.equals(D CMSConstants.US ERTODO_STATUS_P REPARE))
{
update_field = new StringBuffer()
.append(" OFFICER_PREPARE = ?, ")
.append(" DATE_PREPARE = ?, ")
.append(" STATUS = ? ")
.toString();
}else if( status.equals(D CMSConstants.US ERTODO_STATUS_L ULUS))
{
update_field = new StringBuffer()
.append(" OFFICER_APPROVE = ?, ")
.append(" DATE_APPROVE = ?, ")
.append(" STATUS = ? ")
.toString();
}
else if( status.equals(D CMSConstants.US ERTODO_STATUS_T OLAK))
{
if (file_no==null) file_no=xcbo.ge tFile_no();
update_field = new StringBuffer()
.append(" OFFICER_REJECT = ?, ")
.append(" DATE_REJECT = ?, ")
.append(" STATUS = ? ")
.toString();
}
else if( status.equals(D CMSConstants.US ERTODO_STATUS_X CHEAD_TOLAK))
{
if (file_no==null) file_no=xcbo.ge tFile_no();
update_field = new StringBuffer()
.append(" OFFICER_REJECT = ?, ")
.append(" DATE_REJECT = ?, ")
.append(" STATUS = ? ")
.toString();
}
else if( status.equals(D CMSConstants.US ERTODO_STATUS_T ERIMA))
{
file_no=xcbo.ge tFile_no();
update_field = new StringBuffer()
.append(" OFFICER_RECEIVE D = ?, ")
.append(" DATE_RECEIVED = ?, ")
.append(" STATUS = ? ")
.toString();
}
PreparedStateme nt stmt = null;
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE " + tableName + " SET ");
sql.append(upda te_field);
sql.append(" WHERE ");
sql.append(" TAXPAYER_KEY = ?");
sql.append(" AND FILE_NO = ?");
sql.append(" AND TAXTYPE_KEY = ?");
stmt = conn.prepareSta tement(sql.toSt ring());
stmt.setString( 1, session.getUser Bo().getUser_id ());
stmt.setTimesta mp(2, now());
stmt.setString( 3, status);
stmt.setInt(4, taxpayer_key);
stmt.setString( 5, file_no);
stmt.setInt(6, taxtype_key);
stmt.executeUpd ate();
}
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.
Data is not updated into table. I got this error : java.lang.NullP ointerException
[5/24/10 10:11:24:012 SGT] 00000030 SystemErr R java.lang.NullP ointerException
[5/24/10 10:11:24:028 SGT] 00000030 SystemErr R at my.org.hasil.dc ms.grq.dao.XC18 DAO.updateXC18( XC18DAO.java)
[5/24/10 10:11:24:028 SGT] 00000030 SystemErr R at my.org.hasil.dc ms.grq.bo.XC18B O.processXC18(X C18BO.java)
[5/24/10 10:11:24:028 SGT] 00000030 SystemErr R at my.org.hasil.dc ms.grq.web.XC18 Action.performS edia(XC18Action .java)
The program :
1.)my.org.hasil .dcms.grq.web.X C18Action.perfo rmSedia(XC18Act ion.java)
public ActionForward performSedia(
ActionMapping mapping,
ActionForm form,
javax.servlet.h ttp.HttpServlet Request request,
javax.servlet.h ttp.HttpServlet Response response)
{
ActionForward forward=new ActionForward() ;
HttpSession httpSession = request.getSess ion();
MESSession session = (MESSession) httpSession.get Attribute(DCMSC onstants.DCMSCo nstants_MESSESS ION);
TodoparameterFo rm todoForm=(Todop arameterForm)ht tpSession.getAt tribute("todopa ramForm");
XC18BO xcbo=new XC18BO(session) ;
XC18Form xc18form=(XC18F orm)form;
try
{
BeanUtils.copyP roperties(xcbo, todoForm);
BeanUtils.copyP roperties(xcbo, xc18form);
xcbo.setTodo_id (xc18form.getId ());
xcbo.setStatus( DCMSConstants.U SERTODO_STATUS_ SEDIA);
xcbo.processXC1 8(); }catch(Exceptio n e)
{
e.printStackTra ce();
}
forward=mapping .findForward("s uccess");
return forward;
}
2.)my.org.hasil .dcms.grq.bo.XC 18BO.processXC1 8(XC18BO.java)
public void processXC18()
{
try{
setDaoName("my. org.hasil.dcms. grq.dao.XC18DAO ");
requestConnecti on();
XC18DAO xcDao =(XC18DAO)getDA O();
xcDao.insertUse rTodo(this);
XC18DAO xcDao1 =(XC18DAO)getDA O();
xcDao1.updateXC 18(this);
commit();
}
3.) XC18BO.java
public void updateXC18(XC18 BO xcbo) throws SQLException
{
String file_no=xcbo.ge tFileNo();
if (file_no==null) file_no=xcbo.ge tFileNo();
String it_ref_no=xcbo. getIt_ref_no();
int taxpayer_key=xc bo.getTaxpayer_ key();
int taxtype_key = Integer.parseIn t(xcbo.getTaxty pe_key());
String status = xcbo.getStatus( );
String update_field = "";
if ( status.equals(D CMSConstants.US ERTODO_STATUS_S EDIA)
|| status.equals(D CMSConstants.US ERTODO_STATUS_P REPARE))
{
update_field = new StringBuffer()
.append(" OFFICER_PREPARE = ?, ")
.append(" DATE_PREPARE = ?, ")
.append(" STATUS = ? ")
.toString();
}else if( status.equals(D CMSConstants.US ERTODO_STATUS_L ULUS))
{
update_field = new StringBuffer()
.append(" OFFICER_APPROVE = ?, ")
.append(" DATE_APPROVE = ?, ")
.append(" STATUS = ? ")
.toString();
}
else if( status.equals(D CMSConstants.US ERTODO_STATUS_T OLAK))
{
if (file_no==null) file_no=xcbo.ge tFile_no();
update_field = new StringBuffer()
.append(" OFFICER_REJECT = ?, ")
.append(" DATE_REJECT = ?, ")
.append(" STATUS = ? ")
.toString();
}
else if( status.equals(D CMSConstants.US ERTODO_STATUS_X CHEAD_TOLAK))
{
if (file_no==null) file_no=xcbo.ge tFile_no();
update_field = new StringBuffer()
.append(" OFFICER_REJECT = ?, ")
.append(" DATE_REJECT = ?, ")
.append(" STATUS = ? ")
.toString();
}
else if( status.equals(D CMSConstants.US ERTODO_STATUS_T ERIMA))
{
file_no=xcbo.ge tFile_no();
update_field = new StringBuffer()
.append(" OFFICER_RECEIVE D = ?, ")
.append(" DATE_RECEIVED = ?, ")
.append(" STATUS = ? ")
.toString();
}
PreparedStateme nt stmt = null;
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE " + tableName + " SET ");
sql.append(upda te_field);
sql.append(" WHERE ");
sql.append(" TAXPAYER_KEY = ?");
sql.append(" AND FILE_NO = ?");
sql.append(" AND TAXTYPE_KEY = ?");
stmt = conn.prepareSta tement(sql.toSt ring());
stmt.setString( 1, session.getUser Bo().getUser_id ());
stmt.setTimesta mp(2, now());
stmt.setString( 3, status);
stmt.setInt(4, taxpayer_key);
stmt.setString( 5, file_no);
stmt.setInt(6, taxtype_key);
stmt.executeUpd ate();
}
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.
Comment