File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.NullPointerException

 
Dorota Rupniewska
Greenhorn
Posts: 2
Firefox Browser Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello 2 All

My code is really simple, but I get java.lang.NullPointerException



and table sale_daty:


fDate is a parameter (Date). fSala is Integer.
All I want is to check if fDate is already in database. If yes, then check if idSali from this recordset = fSala
Is anyone can help?
 
Jan Cumps
Bartender
Posts: 2577
11
C++ Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Dorata.
At which line is the Exception thrown?
 
Tom Reilly
Rancher
Posts: 618
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help if you post all of your code rather than just snippets and post the full exception trace that says which line of code is causing the NPE. Do you know how to do that? Otherwise, we can only guess. My guess is that either the variable(s) conn or fDate has not been initialized.
 
Ronald Djunaedi
Greenhorn
Posts: 5
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dorota, i hope you dont mind to post a full exception output, since it's hard enough to identify the problem only with the code you posted here...
 
Campbell Ritchie
Sheriff
Pie
Posts: 47244
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch Dorota Rupniewska

Please don't write things like "2" for "to".
 
Dorota Rupniewska
Greenhorn
Posts: 2
Firefox Browser Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's bigger project but I try explain It better:
I have a calendar in a JSP page:

When user change month, days which are in database should be marked red. The rest of my code:




This function always return true so all days are marked red.
To find what's wrong I've changed and shorted this code to:

This short code work fine and there is no NPE. I guess the parameter fDate wasn't in proper format.
Thank you for help

P.S.
Please don't write things like "2" for "to".

ok, I won't do this again
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic