• Post Reply Bookmark Topic Watch Topic
  • New Topic

Stored Procedure DAO - execute method returns NullPointerException  RSS feed

 
Ashley Lewis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was hoping someone could help me out with calling a Stored Procedure that accepts 2 timestamps as inputs and returns a refcursor as the output.


On executing this DAO using my Main class I get the following error

Executing Stored Procedure
Stored Procedure ae.nbad.apm.StoredProcedureDAO$ServiceCountStoredProcedure@2330633a
Calling execute method - internal
retrieveServiceInvocations() : Exception occurred
java.lang.NullPointerException
at org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:167)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1014)
at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1070)
at org.springframework.jdbc.object.StoredProcedure.execute(StoredProcedure.java:144)
at ae.apm.StoredProcedureDAO$ServiceCountStoredProcedure.execute(StoredProcedureDAO.java:84)
at ae.apm.StoredProcedureDAO.retrieveServiceInvocations(StoredProcedureDAO.java:46)
at ae.apm.MainApp.main(MainApp.java:30)

The Stored Procedure I am trying to call is as follows




Additional Classes if required








Can someone help me identify where I am going wrong? Let me know if I need to provide any further information.

Thanks in advance.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing to do would be to check your code on the lines reported StoredProcedureDAO.java:84 and make sure you are not causing a nullpointer exception there by accessing an uninitialized variable.
 
Ashley Lewis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E Armitage wrote:The first thing to do would be to check your code on the lines reported StoredProcedureDAO.java:84 and make sure you are not causing a nullpointer exception there by accessing an uninitialized variable.


Hi E Armitage,

Line number 84 refers to

return execute(inputs);


I do agree that it has something to do with the parameters that I am passing to the execute method but I just can't pinpoint what I'm doing wrong.

Do you have any suggestions or any examples on passing timestamps to a Stored Procedure through Spring?



 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashley Lewis wrote:
Hi E Armitage,

Line number 84 refers to

return execute(inputs);



Are you sure about that? It doesn't look like that is the case in your posted code. It looks like you have another method called execute which accepts a Map and line 84 is somewhere in that method.
 
Ashley Lewis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E Armitage wrote:Are you sure about that? It doesn't look like that is the case in your posted code. It looks like you have another method called execute which accepts a Map and line 84 is somewhere in that method.


Yes, I use Eclipse and clicking on that line in the exception trace of the console leads me to that line of code. The full method is as below



Line 84 is " return execute(inputs);"
 
E Armitage
Rancher
Posts: 989
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, The line that throws that error in the Spring jdbc classes is


Most likely the connection is null. Less likely the callString is null.
 
Ashley Lewis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E Armitage wrote:Ok, The line that throws that error in the Spring jdbc classes is


Most likely the connection is null. Less likely the callString is null.


Thank you for that. I was using an incorrect driver.

I am getting a different exception now related to the JDBC URL but I can work on that. Just need the correct connection String.

Thanks again
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!