6.4 CHAPTER SUMMARY
A popular Java database programming method, the runtime object method, is discussed in detail in this chapter.
This method is discussed with a real sample project, OracleSelectFaculty. With a lot of code development and dynamic parameter setups, some advanced and complicated techniques in Java database programming are discussed and analyzed, which include:
- How to perform a dynamic data query using standard JDBC drivers, such as
1) Load and register database drivers
2) Connect to databases and drivers
3) Create and manage a PreparedStatement object to perform a dynamic query
4) Use a ResultSet object to pick up the queried result
5) Query data using the JDBC MetaData interface
6) The ParameterMetaData interface
7) Use the DatabaseMetaData interface
8) Use the ResultSetMetaData interface
9) Query data using the CallableStatement method
• Query data using the Java RowSet object
The key novel technique discussed in this part is the interface between an Oracle package with a stored procedure and a Java CallableStatement interface. Usually, there is no mapped partner for the cursor data type in the JDBC data type. In other words, a cursor applied in the Oracle stored procedure cannot be returned to a Java database application, since the cursor cannot be mapped to a valid JDBC data type. In order to solve that problem, we developed a special Oracle stored procedure to perform the conversion between a VARCHAR string and a cursor inside the Oracle stored procedure and return a VARCHAR string to the Java database application.
Very detailed discussions of how to build Oracle packages and Oracle stored procedures are provided in this chapter to give readers a clear global picture of how to build an interface between a CallableStatement interface and a database stored procedure. One of the most popular databases, Oracle Database 18c XE, is used in the entire chapter.