File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes java.lang.NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.lang.NullPointerException" Watch "java.lang.NullPointerException" New topic
Author

java.lang.NullPointerException

Dorota Rupniewska
Greenhorn

Joined: Jan 09, 2011
Posts: 2

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

Joined: Dec 20, 2006
Posts: 2500
    
    8

Welcome to the Ranch, Dorata.
At which line is the Exception thrown?


OCUP UML fundamental and ITIL foundation
youtube channel
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
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

Joined: Jan 06, 2011
Posts: 5

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

Joined: Oct 13, 2005
Posts: 38818
    
  23
Welcome to JavaRanch Dorota Rupniewska

Please don't write things like "2" for "to".
Dorota Rupniewska
Greenhorn

Joined: Jan 09, 2011
Posts: 2

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NullPointerException