File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Another infamous NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Another infamous NullPointerException" Watch "Another infamous NullPointerException" New topic
Author

Another infamous NullPointerException

Brian LaRue
Ranch Hand

Joined: Feb 01, 2006
Posts: 45
I'm running Netbeans 6.7.1 and am on Ubuntu 9.10. I'm attempting to author my first swing app which displays a form, takes the information, and then writes it to a database (OpenOffice.org Base). I'm a n00b so bear with me, please.

Here's the error message i get at runtime:


Looks like it's complaining about my executeUpdate method. Here's that code:



I know that there's probably better way(s) to do the above, I guess I'm open for suggestions there as well. This is probably the 4th or 5th revision that I've tried and all are unsuccessful . Where/Why am I getting a NullPointerException?

Background info:

Database Name: Test ( /home/brian/Documents/BaseConnection/Test.odb)
Table Name: Contacts

Any help is appreciated!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18129
    
    8

Yup, line 28. If your line numbers in your post match the line numbers in your actual code, then that's this line:

If you're getting a NPE there, it can only be because the "state" variable is null. Look through the code and try to convince me that it can be anything but null... you won't be able to do it.
Brian LaRue
Ranch Hand

Joined: Feb 01, 2006
Posts: 45
Yeah, my state variable is initialized to null and not used until this executeUpdate() statement. Hmm...lemme take that initialization (to null) out and give it another go.

Edit: That's not it. I changed Statement state = null; (line 8 above) to Statement state; ran the program again and same result: NPE... any other ideas?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Another infamous NullPointerException
 
Similar Threads
error handling
Help with getting the database to take values (Java-MySQL)
Desktop.Action.EMAIL
How to convert arabic numbers received from JTextField to a Double?
nullPointerException on entity manager methods