Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases and the fly likes Another infamous NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Another infamous NullPointerException" Watch "Another infamous NullPointerException" New topic

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 ( 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

Joined: Oct 14, 2005
Posts: 19973

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:
subject: Another infamous NullPointerException
It's not a secret anymore!