CHAPTER SUMMARY – JDBC Applications and Design Considerations



4.3   CHAPTER SUMMARY

The application fundamentals of JDBC and the JDBC API, which include the application models and operational procedures of the JDBC API implemented in Java database applications, are dis-cussed in detail in this chapter.

FIGURE 4.19   A code example of closing the Connection and Statement objects.

Starting with an introduction to two JDBC application models, two-tier and three-tier models, a detailed illustration and description of these two models is given in the first part of this chapter. A typical two-tier model contains an application server and a database server, in which a Java data-base application project resides on an application server and the target database is located on the data-base server. The so-called three-tier model places the application onto an application server that can be considered a middle tier and installs the database on a database server. To run this three-tier model application, the user needs to communicate with the application server by using a Web browser that can be considered a top tier, with a GUI installed in this browser. Then the application server can process requests sent from the browser via the target database via the database server. Finally, when requests have been sent, the results will be returned to the browser by the application server.

Following the application models, a complete operational procedure to perform a standard Java database application is discussed with some example code, including:

  • Load and register a JDBC Driver.
  • Connect to the target database using either the DriverManager.getConnection() method or Driver.connect() method.
  • Execute an Oracle statement by creating and calling an appropriate Statement object, including:
  • Statement object
  • PreparedStatement object
  • CallableStatement object
  • Distinguish different queries by running the associated execute method.
  • Execute DDL and DML Oracle statements.
  • Retrieve run results by creating and getting a ResultSet object.
  • Develop sophisticated Java database applications using different JDBC metadata interfaces, including the ResultSetMetaData, DatabaseMetaData and ParameterMetaData interfaces.
  • Close the connected database and opened statement objects to release data resources used byte application.

Combining the contents in this chapter and the last chapter, you should have a complete and clear picture of JDBC fundamentals and the application procedure. Beginning from the next chapter, we will introduce and discuss some development tools and actual techniques used in Java database applications.

Leave a Reply

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

Related Post