• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to call stored procedure in JDBC

 
Mike Dafel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to call a procedure GET_VAL which returns several "double" values. This procedure has one input parameter that specifies the number of values to be returned.
Can anybody help me with a code snippet to make that possible, please.
Thank you very much.
 
zou xiao fei
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CallableStatement
check jdk doc to find how to use it
 
Rajakumar Makapur
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Hope this will help u
Here the procedure takes 4 integers as parameters
CallableStatement cStmt = null;
try {

cStmt = conn.prepareCall(" { call <proc name>(?,?,?,?)}");

cStmt.setInt(1,<varname1> ;
cStmt.setInt(2,<varname2> ;
cStmt.setInt(3, <varname3> ;
cStmt.setInt(4, <varname4> ;
cStmt.executeUpdate();
}
catch(Exception e){
e.printStackTrace();
} // end of the try-catch block
finally{
try {
cStmt.close();
conn.close();
}
catch(Exception e){}
} // end of the finally block
regards
Raja
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!