• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between CallableStatement and PreparedStatement

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What is the difference between CallableStatement & PreparedStetement ?

Which one is better if i want to execute a procedure ?

Is there any performance issue if i use preparedStatement for calling calling procedure ?
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PreparedStatement is an object that represents a precompiled SQL statement.It is used for executing SQL statements and returning the results it produces

CallableStatement is used to execute SQL stored procedures.The JDBC API provides a stored procedure SQL escape syntax that allows stored procedures to be called in a standard way for all RDBMSs.

You should always use CallableStatement to execute stored procedure. CallableStatement has some additional methods to deal with stored procedure. For instance if your stored procedure has some out parameter, then you can register same using registerOutParameter method, however there is no such method in PreparedStatement.

Shailesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic