• 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

Java lang NullPointerException error

 
Ranch Hand
Posts: 158
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is the function that i m using on two scnerio.

1st Scnerio.
=============
Just click on add button make entry into required fields and click Save Button.

I call this function before saving data into database. If i am calling this function within the form (Class A) then it is working fine and good.

2nd Scnerio
===========
I have 3 classes i.e. Class A, Class B and Class C

While working on Class A i am calling Class B and filling all kind of required data from Class B to global vector in Class C. After setting data from Class B to another Class C via vector, I close down Class B and again going to Class A as it is already opened.

On clicking a single button in Class A to fill my JTable from Class C (Vector), my all data is appearing and working fine.

But while saving as the below function is called i got an error on "Statement" statement i.e. Java.lang.NullPointerException.

System.out.println("Test");
This is not printed.

Can any one tell me why I am getting this error as the same is working in 1st Scnario.

 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks the problem may be with your connection.

cnnd.myDetailCon.

Before you try that line, try printing cnnd with System.out.println(cnnd) to see if it's null.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's generally a bad practise to catch any unspecific Exception:


Instead catch specific (SQL...) Exceptions.
 
Anand Karia
Ranch Hand
Posts: 158
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Keith Lynn

You were right. Problem was there. I mistakenly close the connection from Class C.

Thanks anyway.

javascript: x()
javascript: x()
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic