aspose file tools
The moose likes JDBC and the fly likes How to call stored procedure in JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark "How to call stored procedure in JDBC" Watch "How to call stored procedure in JDBC" New topic
Author

How to call stored procedure in JDBC

Mike Dafel
Greenhorn

Joined: Jul 12, 2001
Posts: 10
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

Joined: Oct 26, 2001
Posts: 9
CallableStatement
check jdk doc to find how to use it
Rajakumar Makapur
Greenhorn

Joined: Jun 23, 2001
Posts: 13
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
 
IntelliJ Java IDE
 
subject: How to call stored procedure in JDBC
 
Threads others viewed
testing a stored procedure
How to call Stored Procedure using jdbcTemplate and store result in object DTO/String/List/Result se
Calling stored procedures from hibernate
Identifier too long exception in SQL server 7
Calling Oracle stored procedures in JRun container
MyEclipse, The Clear Choice