×
☰ See All Chapters

JDBC CallableStatement

  • CallableStatement is used to execute stored procedures available in the database. 

  • Following is the way to create the CallableStatement instance. 

CallableStatement cst = con.prepareCall(“SQL”);

  • 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 cst = con.prepareCall("{CALL PROCEDURENAME(?,?,?)}");

With CallableStatement following is the way JDBC transaction occurs.

jdbc-callablestatement-0
 

Stored procedures will be compiled and always ready for execution. Whenever procedure is called, SQL engine just executes it.

Total time for any request = (request time + execution time + response time).

Example: Total time for any request = 3+ 15 + 3 = 21 secs.

(Assuming that the stored procedure is having 3 SQL queries)

 

 


All Chapters
Author