• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Callable Statement

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two topics ...
https://coderanch.com/t/499454/sr/certification/callable-statement
... and still not in the 'correct' forum. Should be moved to
https://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.
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic