• Post Reply Bookmark Topic Watch Topic
  • New Topic

Don't understand why I get a NullPointerException  RSS feed

 
tangara goh
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi experts,

I got the following stack trace which point to the problem area related to my Connection method.








error at the controller


Hope someone can point out what's wrong with my codes. Tks.
 
Tim Moores
Saloon Keeper
Posts: 3831
80
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code doesn't use a variable called "statement" anywhere - is it ever initialized?

I also note that a variable called "ps" is closed in two places - that may also be a cause for problems later on.

In general, when closing ResultSets, Statements and Connections, it it good practice to precede the close call by a null check like if (ps != null) ps.close();
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!