File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Facing nullpointer exception in Spring JDBC Query. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Facing nullpointer exception in Spring JDBC Query." Watch "Facing nullpointer exception in Spring JDBC Query." New topic

Facing nullpointer exception in Spring JDBC Query.

Robinson Francis

Joined: Aug 16, 2010
Posts: 22
Dear all,

I am facing a null pointer exception while trying to build a Spring JDBC application.

The code that calls the Dao Interface is :

The code for retrieveNodeLocationCount is defined in the Dao class file of as below:
public int retrieveNodeLocationCount(String nodeLocation);

The implementation is defined in this file : as :

For some reason the the execution doesn't reach this portion of code called. Every time I pass the parameters to this method in

It returns a Null Pointer exception.

Is it true that the service poid contains tmm_streamyx?--->false

I am still new at this Spring Jdbc, I was wondering why this problem cropped up. Maybe I missed something. Thank you.
Csabba Csurja

Joined: Jan 12, 2012
Posts: 12

from your posted code I was not able to see what is the statment in line.
Basically, the getJdbcTemplate.queryForInt doesn't throw NullPointerException.
Are you sure that getJdbcTemplate is not null it self, you can check it, if not then give a try to execute a very simple query which is 100% should run (e.g. without any paramter)

I agree. Here's the link:
subject: Facing nullpointer exception in Spring JDBC Query.
It's not a secret anymore!