The advantage of a CallableStatement over a PreparedStatement is that it:
A.
Is easier to construct
B.
Supports transactions
C.
Runs on the database
D.
Uses Java instead of native SQL
Explanation:
A Statement is an interface that represents a SQL statement. You execute
Statement objects, and they generate ResultSet objects, which is a table of data representing a
database result set.
There are three different kinds of statements:
* Statement: Used to implement simple SQL statements with no parameters.
* PreparedStatement: (Extends Statement.) Used for precompiling SQL statements that might
contain input parameters.
* CallableStatement: (Extends PreparedStatement.) Used to execute stored procedures that may
contain both input and output parameters.
A stored procedure is a group of SQL statements that form a logical unit and perform a particular
task, and they are used to encapsulate a set of operations or queries to execute on a database
server.
Reference: The Java Tutorials:
Executing Queries
Using Stored Procedures
A
A CallableStatement is easier to build and call from JDBC code than a PreparedStatement
This is true because you don’t have to write any SQL query in Java code. You just use the name of the stored procedure. The queries are already there inside the stored procedure, which exists in the Database and not in JDBC code.@Enthuware