File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes java.lang.NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "java.lang.NullPointerException" Watch "java.lang.NullPointerException" New topic


Dorota Rupniewska

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

Joined: Dec 20, 2006
Posts: 2562

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

OCUP UML fundamental and ITIL foundation
Tom Reilly

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

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

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

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

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

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

ok, I won't do this again
I agree. Here's the link:
subject: java.lang.NullPointerException
jQuery in Action, 3rd edition