aspose file tools
The moose likes JDBC and the fly likes Callable Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Callable Statement" Watch "Callable Statement" New topic
Author

Callable Statement

sa sam
Ranch Hand

Joined: Mar 01, 2009
Posts: 46
i am facing problem with callablestatement , the problematic part of my application is as follows

Stored Procedure-

CREATE PROCEDURE [dbo].[LOG]
@id int,
@name text OUTPUT,
@Rno int OUTPUT
AS
SELECT @name = Name, @Rno = Roll_No
FROM [login].[dbo].[Logger]
WHERE ID = @id



CallableStatement cs = con.prepareCall("{call LOG(?,?,?)}");
cs.setInt("@id", 121);
cs.registerOutParameter("@name",Types.VARCHAR);
cs.registerOutParameter("@Rno", Types.INTEGER);
cs.execute();
System.out.println(cs.getString("@name")+" "+cs.getInt("@Rno"));


when i use the above code i get the output but, when i use the parameters name instead of index value it give me the error message.

Exception in thread "main" java.lang.UnsupportedOperationException
at sun.jdbc.odbc.JdbcOdbcCallableStatement.registerOutParameter(Unknown Source)
at pcs.data.SQL_Execute.executeUpdate(SQL_Execute.java:22)
at pcs.data.SQL_Execute.main(SQL_Execute.java:79)
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
Two topics ...
http://www.coderanch.com/t/499454/sr/certification/callable-statement
... and still not in the 'correct' forum. Should be moved to
http://www.coderanch.com/forums/f-3/JDBC

Take a look into the API docs:
http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html#registerOutParameter(java.lang.String, int)

The JDBC driver has to support the 'sqlType'. It seems sql3 data types may not be supported yet.


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Callable Statement
 
Similar Threads
Can't declare a Sybase Cursor for StoredProcedures using Spring
calling oracle procedures in java
how to pass arrayList to calling Procedure
Serious error in JPA with @Version
callable statement