Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Got Nullpointer Exception

 
shiva mistry
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I try to insert student in Database I got an exception like Nullpointer Exception can any one help please ?






 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which line of code are you getting the exception? Post the entire stack trace.

Have you verified that "con" is not null? You didn't post code that assigns a value to "con".
 
shiva mistry
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:In which line of code are you getting the exception? Post the entire stack trace.

Have you verified that "con" is not null? You didn't post code that assigns a value to "con".



Here is that code : I am getting an Exception at line 28

 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it's probably "con" that's null - that means you probably got a stack trace in line 18; correct?
 
shiva mistry
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:So it's probably "con" that's null - that means you probably got a stack trace in line 18; correct?


Hi Ulf, I forgot to define con in default constructor now it's working Thanks..





 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic