Two Laptop Bag*
The moose likes JDBC 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can someone look at program" Watch "Can someone look at program" New topic
Author

Can someone look at program

manishjain Jain
Greenhorn

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.

Thanks
Manish Jain


Manish Jain
Paul Sturrock
Bartender

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 ]

http://home.arcor.de/hirnstrom/bewerbung
manishjain Jain
Greenhorn

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.

Thanks
Manish
 
 
subject: Can someone look at program