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

How to call one constructor from the other constructor ?

606


What is the meaning of nullable?

576


Why are the objects immutable in java?

546


What is :: operator in java?

509


Can we override the static methods?

572






When should you use arraylist and when should you use linkedlist?

496


Can we have multiple public classes in a java source file?

558


Do we need to manually write Copy Constructor?

606


What is intern method in java?

583


What is the difference between compile-time polymorphism and runtime polymorphism?

566


What is the largest data type in java?

510


What is thread safe in java?

553


What is the original name of java?

544


Can we use synchronized block for primitives?

604


What is used of static keyword in java?

592