This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Can someone look at program 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 "Can someone look at program" Watch "Can someone look at program" New topic

Can someone look at program

manishjain Jain

Joined: Jul 08, 2004
Posts: 8
Hi all,

I just made the new program which actully compiles with no error but if run this program it give me the error of :Exception in thread "main " java.lang,NullPointerException

My program is as below:

Can someone plz look at it ....I will really appreciate if some one will help me.

Manish Jain

Manish Jain
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Post the full stack trace and people will help.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

We prefer a linenumber, and a mark, where this line is in the source-code, because we don't like counting to 297, and small differences in the layout may confuse our counting.

... but I found it without that.

You declare 'Statement statement' and 'Connection connection' in your class.
While initialising, you declare a new 'Statement statement' and 'Connection connection' in main, only locally visible, and hiding the class-attribut.
Later the local variable is out of scope - invalid, invisible, - and the class-member is used.
Which is null - has never been initialised.
[ July 28, 2004: Message edited by: Stefan Wagner ]
manishjain Jain

Joined: Jul 08, 2004
Posts: 8
Hi Stefan,

Thankyou very much. It solved my problem. I must say you are very knowledgeble and very nice. Thanks for a such a great help from you.

I agree. Here's the link:
subject: Can someone look at program
It's not a secret anymore!