Meaningless Drivel is fun!*
The moose likes JDBC 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
Bookmark "Difference between CallableStatement and PreparedStatement" Watch "Difference between CallableStatement and PreparedStatement" New topic
Author

Difference between CallableStatement and PreparedStatement

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
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 ?


Jigar Naik


Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

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


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between CallableStatement and PreparedStatement