what r callable statement and give their proper use

Answer Posted / prajal

Callable statement (java.sql.CallableStatement) are used for
calling a Stored Procedure.

Syntax is as below-
//prepare a procedure call
String procedureCall="call testProcedure(:1,:2,:3)";
//prepare a callable statement

CallableStatement
cStmt=connectionObject.prepareCall(procedureCall);

// Set the Input Parameters to the procedure
cStmt.setInt(1, testID);
cStmt.setInt(2, testNumber);

// Register Output Parameters
cStmt.registerOutParameter(3, Types.VARCHAR);

// Execute the Callable Statement
cStmt.execute();

// Resulting Values from the Callable Statement is assigned
to the Message variable
String message = cStmt.getString(3);

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string builder?

477


In which order the iterator iterates over collection?

590


How many bits is a boolean?

628


What is the length of a string?

531


How does list work in java?

512






In how many ways we can do synchronization in java?

533


Can you make a constructor final?

586


What is class variable java?

592


Can we serialize static variables in java?

661


How to provide security in java

1807


Explain the use of sublass in a java program?

599


What is the full form of jpeg?

527


What is static import in java?

536


Can inner class final?

641


Can we override private method in java?

626