REPLACEMENT FOR EXERCISE 31.3:
(Phone Book Web Service) Create a web service that stores phone book entries in the database PhoneBookDB and a web client application that consumes this service. Use the steps in Section 30.2.1 to create the PhoneBook database. The database contains one table—PhoneBook—with three columns—LastName, FirstName and PhoneNumber—each of type VARCHAR. The LastName and FirstName columns store up to 30 characters. The PhoneNumber column should support phone numbers of the form (800) 555-1212 that contain 14 characters.
Give the client user the capability to enter a new contact (web method addEntry) and to find contacts by last name (web method getEntries). Pass only Strings as arguments to the web service. The getEntries web method should return an array of Strings that contains the matching phone book entries. Each String in the array should consist of the last name, first name and phone number for one phone book entry. These values should be separated by commas.
The SELECT query that will find a PhoneBook entry by last name should be:
SELECT LastName, FirstName, PhoneNumber
WHERE (LastName = LastName)
The INSERT statement that inserts a new entry into the PhoneBook database should be:
INSERT INTO PhoneBook (LastName, FirstName, PhoneNumber)
VALUES (LastName, FirstName, PhoneNumber)
[Note: Here is the SQL code to create the database]
DROP TABLE PhoneBook;
CREATE TABLE PhoneBook
FirstName VARCHAR (50) NOT NULL,
LastName VARCHAR (50) NOT NULL,
PhoneNumber VARCHAR (50) NOT NULL
INSERT INTO PhoneBook (FirstName,LastName,PhoneNumber)
VALUES ('Bob', 'Green', '5555551111'),
('Sue', 'Black', '5555552222'),
('Liz', 'White', '5555553333'),
('Paul', 'Blue', '5555554444')
REPLACEMENT FOR EXERCISE 31.4:
(Phone Book Web Service Modification) Modify Exercise 31.3 so that it uses a class named PhoneBookEntry to represent a row in the database. The client application should provide objects of type PhoneBookEntry to the web service when adding contacts and should receive objects of type PhoneBookEntry when searching for contacts.