aspose file tools
The moose likes JDBC and the fly likes calling stored procedure Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "calling stored procedure" Watch "calling stored procedure" New topic
Author

calling stored procedure

Donna Reschke
Greenhorn

Joined: Jul 05, 2001
Posts: 23
If I need to call a stored procedure with 6 input parameters and 6 output parameters, how would I do this? Would it look like this?...
cstmt = con.prepareCall("{?, ?, ?, ?, ?, ? = CALL MKTDS22B (?, ?, ?, ?, ?, ?)}");
or this?...
cstmt = con.prepareCall("(CALL MKTDS22B (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?))" );
Please help! Thanks!
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

this:
assume that in your stored procedure that the first 6 parameters are out parameters and the last 6 are in parameters(note, use curly braces in your prepareCall string):

cstmt.registerOutParameter(1, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(2, java.sql.Types.INTEGER);
...
cstmt.registerOutParameter(6, java.sql.Types.VARCHAR);
cstmt.setString(7, "some string");
cstmt.setInt(8, 200145);
...
cstmt.setString(12, "some string");
cstmt.execute();
//process the results.[/code]
Jamie
prabhatis
Greenhorn

Joined: Apr 07, 2001
Posts: 18
hi, sorry for the late posting . i was busy.
here is the soln,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling stored procedure
 
Similar Threads
Confused by stored procedure sql error
Confused by Stored Procedure Error
MS SQL Server and Java...
Calling stored procedures from Java Servlet
stored procedure giving me sql error