Class PersonQueries

Class PersonQueries (Fig. 24.31) manages the address book application’s database connection and creates the PreparedStatements that the application uses to interact with the database. Lines 18–20 declare three PreparedStatement variables. The constructor (lines 23–49) connects to the database at lines 27–28.

 1   // Fig. 24.31: PersonQueries.java 2   // PreparedStatements used by the Address Book application. 3   import java.sql.Connection; 4   import java.sql.DriverManager; 5   import java.sql.PreparedStatement; 6   import java.sql.ResultSet; 7   import java.sql.SQLException; 8   import java.util.List; 9   import java.util.ArrayList;10 11   public class PersonQueries12   {13      private static ...

Get Java™ How To Program (Early Objects), Tenth Edition 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.