To execute a stored procedure "totalStock" in a database server, which of the following code snippet is used?

Options
- Statement stmt = connection.createStatement(); stmt.execute("totalStock()");
- CallableStatement clbstmnt = con.prepareCall("{call totalStock}"); cs.executeQuery();
- StoreProcedureStatement spstmt = connection.createStoreProcedure("totalStock()"); spstmt.executeQuery();
- PrepareStatement pstmt = connection.prepareStatement("totalStock()"); pstmt.execute();


CORRECT ANSWER : CallableStatement clbstmnt = con.prepareCall("{call totalStock}"); cs.executeQuery();

Discussion Board
Callable Statement

A CallableStatement can return one ResultSet object or multiple ResultSet objects. Multiple ResultSet objects are handled using operations inherited from Statement. To execute a stored procedure "totalstock" in a database server the snippet used is as follows:

CallableStatement clbstmnt = con.prepareCall("{call totalStock}"); cs.executeQuery();

To have maximum portability, ResultSet objects and update counts should be processed prior to getting the values of output parameters.

Rohit Sharma 09-21-2014 04:13 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement