How to call a Stored Procedure from JDBC?

Answer Posted / gajendra

We can use CallableStatement interface to call a stored
procedure.Use the following steps.

1. crate the escape syntax like
String sql="{call procname(?,?,?);
2.CallableStatement cst=con.prepareCall(sql);
3.Set the inparameters using setXXX methods like
cst.setInt(1,10);
cst.setString(2,"abc");
4.Register the out parameter
cst.registerOutParameter(1,Types.Float);
5.Submit the statement using
cst.execute();
6. We can get the data from stored procedure using getXXX
methods

Is This Answer Correct ?    4 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why java is made?

561


Explain naming conventions for packages?

573


Is static a keyword in java?

519


What are peerless components?

616


Can finally block be used without a catch?

540






If an object is garbage collected, can it become reachable again?

538


What is %02d?

573


Does sprintf add a null terminator?

556


What is the difference between Java Program Constructor and Java Program Method, What is the purpose of Java Program constructor Please Explain it Breafily?

595


What is a generic type?

556


Can we pass a primitive type by reference in java? How

525


What is a copy constructor in java?

574


What is collection sort in java?

549


Explain all java features with real time examples

1204


What is the advantage of functional interface in java 8?

515