4.2 JDBC APPLICATION FUNDAMENTALS As we discussed in Section 3.1 in Chapter 3, to run a Java database application to perform data actions against the selected database, the JDBC API
Category: Establish a Database Connection
Getting Connected – JDBC Applications and Design ConsiderationsGetting Connected – JDBC Applications and Design Considerations
4.2.2 Getting Connected To establish a connection to the desired database, two methods can be used: Before we can take a closer look at these two methods, first let’s have
Using the Statement Object – JDBC Applications and Design ConsiderationsUsing the Statement Object – JDBC Applications and Design Considerations
4.2.3.2 Using the Statement Object As we discussed in the last section, three separate statement objects can be created based on three different data actions: Statement, PreparedStatement and CallableStatement. Let’s
Creating the PreparedStatement Object – JDBC Applications and Design ConsiderationsCreating the PreparedStatement Object – JDBC Applications and Design Considerations
4.2.3.3.1 Creating the PreparedStatement Object Refer to Table 4.3. The prepareStatement() method defined in the Connection interface is used to create a PreparedStatement object. Example code to create a PreparedStatement
Executing the PreparedStatement Object – JDBC Applications and Design ConsiderationsExecuting the PreparedStatement Object – JDBC Applications and Design Considerations
4.2.3.3.4 Executing the PreparedStatement Object As we discussed in Section 3.3.2 in Chapter 3, three execution methods can be called to perform the data action against the database. Refer to
Using the CallableStatement Object – JDBC Applications and Design ConsiderationsUsing the CallableStatement Object – JDBC Applications and Design Considerations
4.2.3.4 Using the CallableStatement Object As we discussed in the early part of this chapter, CallableStatement is a subclass of both Statement and PreparedStatement, and this interface is mainly used
The ResultSet Interface – JDBC Applications and Design ConsiderationsThe ResultSet Interface – JDBC Applications and Design Considerations
4.2.4.1 The ResultSet Interface Data is stored in a ResultSet just as it is returned by the database: it is stored in tabular format. Each field of the database can
Getting and Processing the ResultSet Object 2 – JDBC Applications and Design ConsiderationsGetting and Processing the ResultSet Object 2 – JDBC Applications and Design Considerations
Figure 4.15a shows an initial cursor position of a ResultSet object in which an execution method has just completed and a ResultSet object is created. The cursor now points to
Getting and Processing the ResultSet Object – JDBC Applications and Design ConsiderationsGetting and Processing the ResultSet Object – JDBC Applications and Design Considerations
4.2.4.2 Getting and Processing the ResultSet Object When an Oracle data query is executed, the returned result is stored in a ResultSet object, and this ResultSet object can be created
Using JDBC MetaData Interfaces – JDBC Applications and Design ConsiderationsUsing JDBC MetaData Interfaces – JDBC Applications and Design Considerations
4.2.5 Using JDBC MetaData Interfaces In addition to general and popular data information provided by three statement interfaces and execution methods, JDBC also provides useful and critical information and descriptions