• 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

Another infamous NullPointerException

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic