• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 1.3.8: Trying to write to a MySQL db

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,
I'm writing a hospital automation app in Struts 1.3.8 for a software development class and I'm having trouble writing out to a MySQL database. Specifically, the classes I'm having a problem with are for handling the situation where a patient is already logged into their account and are trying to check-in to the hospital. So they fill out a form and hit submit and then my java is supposed to take the userID from the session attributes and use that as a key for changing a status variable in the database.
I think I have it ready to go, but I keep getting a 500 error:

root cause

java.lang.NullPointerException
database.generalDAO.checkinPatient(Unknown Source)
patient.CheckInAction.execute(Unknown Source)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Here's my classes:
CheckInAction.java

CheckInForm.java

and our DAO


Any suggestions? This problem has been haunting me for hours and I can't find anything that points toward a solution. Sorry about dropping that much code in my first post.
Thanks,

Kyle
[ November 08, 2008: Message edited by: Kyle Oliveira ]
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you figured out which object in checkinPatient is null yet? I don't see your declaration for that connection object, so that could be it. Either that or your or the excecture call is returning null and its failing on statement.close(). I suppose it could also be caused by a null user id being passed in. Try using a debugger or output statements to narrow down which variable is null.
 
Kyle Oliveira
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. We just solved the problem. The guy in my group who set up the DAO forgot to mention that he made the connection method automatically close after each execute. So I was getting the null pointer because I was trying to close the connection twice.

-Kyle
[ November 08, 2008: Message edited by: Kyle Oliveira ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic