File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Callable Statement" Watch "Callable Statement" New topic

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-

@id int,
@name text OUTPUT,
@Rno int OUTPUT
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("@Rno", Types.INTEGER);
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)
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
Two topics ...
... and still not in the 'correct' forum. Should be moved to

Take a look into the API docs:, 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
subject: Callable Statement
It's not a secret anymore!