This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes customerDAO returning NPE error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "customerDAO returning NPE error" Watch "customerDAO returning NPE error" New topic
Author

customerDAO returning NPE error

Charles Sexton
Ranch Hand

Joined: Sep 26, 2013
Posts: 160
I am relatively new to the data access object structure, which can be found here http://www.oracle.com/technetwork/java/dataaccessobject-138824.html. I am pretty sure that I am doing something wrong. I am trying to get the application running incrementally so the app doesn't really do much except get first name and last name of user input and then uses the database to retrieve that particular customer details. Here is the error that I am receiving and the code is below that. I also apologize for the bad formatting in the code. I don't normally format till I have a completed application but am learning to do it as I go as it reduces time by not having to go back through the code.





This class is in the customer class which basically gets the user input from the web page and sends the request back. Didn't post all the code because mostly getters and setter plus variable initialization.





Database connection class



customerDataAccessObject Class

Charles Sexton
Ranch Hand

Joined: Sep 26, 2013
Posts: 160
I have also tried it a different way but it returns the same NPE error.




Here is what I changed from the data access object. I included the whole customer class in case something is in correct.






Charles Sexton
Ranch Hand

Joined: Sep 26, 2013
Posts: 160
also here is the webpage

incase if anyone needs

Charles Sexton
Ranch Hand

Joined: Sep 26, 2013
Posts: 160
It was a little more complicated than a NPE, but solved it on my own. Actually had to re-install netbeans and MySQL. Then changed quite a bit of code after a few hours of research and it worked great......Just wanted to add this to reply incase anyone looks at the thread
 
jQuery in Action, 2nd edition
 
subject: customerDAO returning NPE error
 
Similar Threads
Could not resolve a persistence unit corresponding to the persistence-context-ref-name
Client GUI gets hung after user input
Designing an address book in Java
NPE
Applet Reading from Excel Sheet