File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes callable statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked 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)
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2476
    
    7

Duplicate of http://www.coderanch.com/t/499457/JDBC/java/Callable-Statement
I'm moving this to the right forum, and loch this thread. Please continue in the other thread.


OCUP UML fundamental and ITIL foundation
youtube channel
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: callable statement
 
Similar Threads
Callable Statement
calling oracle procedures in java
Serious error in JPA with @Version
Can't declare a Sybase Cursor for StoredProcedures using Spring
how to pass arrayList to calling Procedure