Oracle Exams Exams of Oracle,Oracle Certification Exam,The ResultSet Interface Executing Statements 2 – JDBC Applications and Design Considerations

Executing Statements 2 – JDBC Applications and Design Considerations



CallableStatement is also a subclass of the Statement and the PreparedStatement classes, and it is mainly used to execute stored procedures with both IN and OUT parameters. As we know, stored procedures are built and developed inside databases and therefore have higher run and response efficiency in data queries and processing.

This interface is used to execute Oracle stored procedures. The JDBC API provides a stored pro-cedure escape syntax that allows stored procedures to be called in a standard way for all RDBMSs. This escape syntax has one form that includes a result parameter and one that does not. If used, the result parameter must be registered as an OUT parameter. The other parameters can be used for input, output or both. Parameters are referred to sequentially, by number or position, with the first parameter being 1.

{?= call <procedure-name>[(<arg1>,<arg2>, . . .)]} {call <procedure-name>[(<arg1>,<arg2>, . . .)]}

The IN parameter values are set using the setXXX() methods inherited from the interface PreparedStatement. The type of all OUT parameters must be registered prior to executing the stored procedure; their values are retrieved after execution via the getXXX() methods defined in this CallableStatement interface.

A CallableStatement can return one ResultSet object or multiple ResultSet objects. Multiple ResultSet objects are handled using operations inherited from the Statement interface. The CallableStatement interface contains over 30 methods, and Table 4.6 lists the 15 most popular methods.

The registerOutParameter() method is an overloaded method with two signatures, and these methods are used to declare what Oracle type the OUT parameter will return when a CallableStatement method is executed.

By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a Statement’s current ResultSet object if an open one exists.

The Statement interface contains three important query methods with different functions: exe-cuteQuery(), executeUpdate() and execute(). For each method, different operations can be performed and different results will be returned.

Generally, query methods can be divided into two categories: 1) the query method that needs to perform a data query, such as executeQuery(), which returns an instance of ResultSet that contains the queried results, and 2) the query method that does not perform a data query and only returns an integer, such as executeUpdate(). An interesting method is execute(), which can be used either way.

Let’s first concentrate on the creation of Statement objects based on the different requirements of data actions.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post