callable is interface or class ?

Answer Posted / kuldeep raaj sharma

The Statement is an interface and its subclasses are
PreparedStatement and CallableStatement.

The Statement interface defines methods for executing SQL
statements that do not contain parameter markers. The
PreparedStatement interface adds methods for setting input
parameters, and the CallableStatement interface adds
methods for retrieving output parameter values returned
from stored procedures.

The CallableStatement interface extends PreparedStatement
with methods for executing and retrieving results from
stored procedures.

Creating a CallableStatement Object
As with Statement and PreparedStatement objects,
CallableStatement objects are created by Connection
objects. CODE EXAMPLE 13-18 shows the creation of a
CallableStatement object for calling the stored
procedure ‘validate’, which has a return parameter and two
other parameters.

CallableStatement cstmt = conn.prepareCall(
“{? = call validate(?, ?)}”);

Setting Parameters
CallableStatement objects may take three types of
parameters: IN, OUT, and
INOUT. The parameter can be specified as either an ordinal
parameter or a named
parameter. A value must be set for each parameter marker in
the statement.
The number, type, and attributes of parameters to a stored
procedure can be
determined using the DatabaseMetaData method
getProcedureColumns.
Parameter ordinals, which are integers passed to the
approriate setter method, refer to the parameter markers
("?") in the statement, starting at one. Literal parameter
values in the statement do not increment the ordinal value
of the parameter markers.
In CODE EXAMPLE the two parameter markers have the ordinal
values 1 and 2.
CallableStatement cstmt = con.prepareCall(
"{CALL PROC(?, "Literal_Value", ?)}");
cstmt.setString(1, "First");
cstmt.setString(2, "Third");

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is database connection pooling? Advantages of using a connection pool?

543


How do I insert/update records with some of the columns having NULL value?

514


I have the choice of manipulating database data using a byte[] or a java.sql.blob. Which has best performance?

485


Which jdbc driver is the fastest driver?

553


How you restrict a user to cut and paste from the html page using java programing?

482






What are the advantages of using preparedstatement over statement?

540


In which ways is driver class is registered with drive manager?

529


What is jdbc class forname?

491


Which jdbc drivers will run your program?

518


What is device controller?

524


Explain the various types of locking system in jdbc?

497


How do I disallow NULL values in a table?

544


How can you retrieve data from the resultset using jdbc?

553


What is addbatch jdbc?

535


What is phantom read and which isolation level prevents it?

503