473,416 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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

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
3 4267
ThatThatGuy
449 Expert 256MB
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
2,057 Expert 2GB
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
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

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

Similar topics

0
by: JeffRoot | last post by:
I receive the following error message when I try to run the Database Configuration Assistant on Solaris 8 / Oracle 9i. Does anyone know the solution to this problem? I thought it might have...
1
oll3i
by: oll3i | last post by:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at Zad21.Cennik.getCenna(Cennik.java) at Zad21.KwiaciarniaView$1.actionPerformed(KwiaciarniaView.java) at...
12
nomad
by: nomad | last post by:
Hi everyone; My Class has ended and I was not able to solve this problem in time, and I would still like to solve it. I got these error code. Exception in thread "main"...
3
sammyboy78
by: sammyboy78 | last post by:
Hello again, This time I'm creating a program that creates an array of CD objects and then displays the information. I've created a CD class, a CDInventory class and then a CDInventoryDisplay to...
2
by: chokcheese | last post by:
I'm having trouble with a java application. When I try and run the program it shows a java.lang.NullPointerException in the "tic.getClient().getClientTicketList().add(tic);" line (it's in bold). I...
2
by: josephx | last post by:
Hello, I got some of these errors listed below after executing an HTTP Post MIDlet on CLDC/MIDP platform, "Nokia S40 DP 2.0 SDK 1.1" and "S40 5th Edition SDK Feature Pack 1" and even for S60's...
1
by: ksrashmi | last post by:
HI I am getting following exception when i use mxml tags in jsp <%@ taglib uri="FlexTagLib" prefix="mm" %> can any one tell why i am getting this exception type Exception report message...
2
by: lilyumestar | last post by:
This project is due by Tuesday and I haven't even gotten half of it done. Can anyone please help me with this Exception error? I've been trying to figure it out for several hours Error Message ...
3
by: ohadr | last post by:
hi, i get Exception in thread "main" java.lang.NullPointerException when i run my application. the exact error is: "Exception in thread "main" java.lang.NullPointerException at...
1
by: onlinegear | last post by:
HI i am writing this for college i know i have loads of combo boxes with nothing in the i havent got that far yet. but every time i run this is comes up with this erro run: Exception in thread...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.