10.1. JDBC 2.0 Core API
The JDBC API provides data access through three basic steps:
- Establish a connection with a data source
- Send queries or update (SQL) statements to the DBMS
- Process the results
The code fragment in Figure 253 on page 372 shows a simple example of accessing the table sample in the data source employees. The code creates a connection using the DriverManager interface (JDBC 1.0), creates an SQL query statement to obtain three fields (the employee number, the employee first name, and the employee last name), and then iterates through the ResultSet.
Figure 253. Sample program using the DriverManager interface
try { Connection conn = DriverManager.getConnection(dbDriver,userid,password); Statement stmt = conn.createStatement(); ... |
Get WebSphere V3.5 Handbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.