It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes Difference between CallableStatement and PreparedStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Difference between CallableStatement and PreparedStatement" Watch "Difference between CallableStatement and PreparedStatement" New topic

Difference between CallableStatement and PreparedStatement

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 761

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 ?

Jigar Naik

Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082

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.


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
I agree. Here's the link:
subject: Difference between CallableStatement and PreparedStatement
jQuery in Action, 3rd edition