• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

AWT

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sir When I run this code I get a NullPointerException.Please help me in finding the reason for this error in my code.


 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to state exactly where the NPE is happening. Paste in the exactly, complete error message, including the stack trace, and make it clear which line is causing it.
 
Saloon Keeper
Posts: 7488
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never do this:


catch(Exception ex)
{
///////////////
}


At the very least print a message to where you will see it. For example, if there's a problem in line 134 or 135, the con or st variables will be null, yet you won't know anything about it.
 
Manoj Syoran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sir I am sending image of exception on the commandline
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something isn't right with that image. Just tell us which line of the code you've posted the error is occurring on (you'll have to convert the file line number it's reporting to you to the line of code that you've posted, if they aren't exactly the same).
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Manoj Syoran wrote:Sir I am sending image of exception on the commandline



PostTextNotScreenshots (<-- It's a link. Click it.)

And of course we can't see your image. Did you notice that it is rooted at your C: drive? You wouldn't expect the entire world to be able to get to your computer just via "C:", would you?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can capture the text in a Command Prompt window as simple text - screen shots are a waste of bandwidth and wont show the entire stack trace.

1. right click on the upper left corner to get a menu
2. pick the Edit -> select all option - selected text will be highlighted
3. press enter - text will be on clipboard
 
Manoj Syoran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sir, Here is the error code.
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Manoj Syoran wrote:


In your actionPerformed method, on line 217, you are adding something that's null to a container. I see only one line that could be the cause, p8.add(lbl[i]);. This would mean that lbl[i] is null, and that can only be the case if your database query returned 0 results.
 
Yeah, but is it art? What do you think tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic