Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use the getDate() method with a callable statement?

 
Jean Fore
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have the following code.
String str = "{? = call uspTestProcedure()}";

try
{
CallableStatement cs = con.prepareCall(str.toString());
cs.registerOutParameter(1, Types.DATE);
cs.execute();
System.out.println("Store Proc result "+ ((Date)cs.getDate(1)).toString());
}
catch(Exception ex)
{ System.out.println("Error while calling the stored procedure "+ex.getMessage());}
}
-------------------------------------------------
And I have the following stored procedure "uspTestProcedure"
-------------------------------------------------------------
CREATE PROCEDURE dbo.uspTestProcedure(@dos datetime OUT) AS
select @dos=UserBooks.DOS from UserBooks, Books where Books.bookid ='B000000001'
GO

But the callable statement execution is throwing the following ERROR.
-----------------------------------------------------------
Error while calling the stored procedure [Microsoft][SQLServer 2000 Driver for J
DBC][SQLServer]Procedure 'uspTestProcedure' expects parameter '@dos', which was
not supplied.
--------------------------------------------------------------------

Do you have any idea how to sort this out?
Thanks
-JEAN
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not familiar with SQL server, but I guess problem at the place when you are calling your store procedure. You are prepearing your call as
String str = "{? = call uspTestProcedure()}";

you should have defined the string as



Shailesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic