How to call a Stored Procedure from JDBC?

Answer Posted / rama krishna dwadasi

By using CallableStatement we can call a stored Procedure
from JDBC

CallableStatement:- is an interface available in java.sql
package and is extending PreparedStatement interface.
•It is used to execute stored procedures available in the
database.
•Following is the way to create the CallableStatement object.
a)CallableStatement cs = con.prepareCall(sql);
b)CallableStatement cs = con.prepareCall(sql,int,int);
•One CallableStatement object can be used to invoke one
stored procedure only.
•CallableStatement also provides placeholder mechanism
•Following is the way to invoke the stored procedure.
CallableStatement cs = con.prepareCall(“{call p1 (?,?)}”);

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we sort hashmap in java?

532


Can we declare an interface as final?

576


What is the history of java?

548


What is hash table in java?

494


What is the difference between quicksort & mergesort? When should they be used? What is their running time?

655






What is unicode with example?

614


Is simpledateformat safe to use in the multithreaded program?

541


What are structs in java?

573


What is the main use of java?

574


Explain the difference between an object-oriented programming language and object-based programming language?

549


Does java set allow duplicates?

528


What is the purpose of the enableevents() method?

585


Why java is called not pure object oriented language?

581


Which object oriented concept is achieved by using overloading and overriding?

557


How to sort an unsorted array in java?

612