aspose file tools
The moose likes JDBC and the fly likes How to use the getDate() method with a callable statement? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "How to use the getDate() method with a callable statement?" Watch "How to use the getDate() method with a callable statement?" New topic
Author

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

Jean Fore
Ranch Hand

Joined: Feb 23, 2006
Posts: 33
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

Joined: Aug 13, 2004
Posts: 1076

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


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
 
I agree. Here's the link: http://jrebel.com/download
 
subject: How to use the getDate() method with a callable statement?
 
Similar Threads
%rowtype mapping in java
java.sql.SQLException: Callable Statements not supported
Collection as a parameter in a Callable Statement
Problem calling IN parameters Stored Procedure from Java
calling of stored procedure with out parater in hibernate?