5.12

Write a Java program that allows university administrators to print the teaching record of an instructor:

  1. Start by having the user input the login ID and password; then open the proper connection.

  2. The user is asked next for a search substring and the system returns (ID,name) pairs of instructors whose names match the substring. Use the like (‘%substring%’) construct in SQL to do this. If the search comes back empty, allow continued searches until there is a nonempty result.

  3. Then the user is asked to enter an ID number, which is a number between 0 and 99999. Once a valid number is entered, check if an instructor with that ID exists. If there is no instructor with the given ID, print a reasonable message and quit.

  4. If the instructor has taught no courses, print a message saying that. Otherwise print the teaching record for the instructor, showing the department name, course identifier, course title, section number, semester, year, and total enrollment (and sort those by dept_name, course_id, year, semester).

Test carefully for bad input. Make sur your SQL queries won’t throw an exception. At login, exceptions may occur since the user might type a bad password, but catch those exceptions and allow the user to try again.


// TODO #1.