36.5. Developing Three-Tier Applications Using RMI

 
[Page 1121 ( continued )]

Programming Exercises

32.1* ( Accessing and updating a Staff table ) Write a Java applet that views, inserts , and updates staff information stored in a database, as shown in Figure 32.24. The view button displays a record with a specified ID. The Staff table is created as follows :
   create table   Staff (    id   char   (9)   not null   ,   lastName   varchar   (15),   firstName   varchar   (15),   mi   char   (1),   address   varchar   (20),   city   varchar   (20),   state   char   (2),   telephone   char   (10),   email   varchar   (40),   primary key   (id) ); 

Figure 32.24. The applet lets you view, insert, and update staff information.



[Page 1122]
32.2** ( Displaying data ) Write a program that displays the number of students in each department in a pie chart and a bar chart, as shown in Figure 32.25. The number of students for each department can be obtained from the Student table (see Figure 32.4) using the following SQL statement:
   select   deptId, count(*)   from   Student   group by   deptId; 

Figure 32.25. The PieChart and BarChart components display the query data obtained from the data module.


Use the PieChart component and the BarChart component created in Programming Exercise 30.1 to display the data.

32.3* ( Connection dialog ) Develop a JavaBeans component named DBConnectionPanel that enables the user to select or enter a JDBC driver and a URL and to enter a username and password, as shown in Figure 32.26. When the OK button is clicked, a Connection object for the database is stored in the connection property. You can then use the getConnection() method to return the connection.
Figure 32.26. The DBConnectionPanel component enables the user to enter database information.



[Page 1123]
32.4* ( Finding grades ) Listing 32.2, FindGrade.java, presented an applet that finds a student's grade for a specified course. Rewrite the program to find all the grades for a specified student, as shown in Figure 32.27.
Figure 32.27. The applet displays the grades for the courses for a specified student.

32.5* ( Displaying table contents ) Write a program that displays the content for a given table. As shown in Figure 32.28(a), you enter a table and click the Show Contents button to display the table contents in the text area.
Figure 32.28. (a) Enter a table name to display the table contents. (b) Select a table name from the combo box to display its contents.

32.6* ( Finding tables and show their contents ) Write a program that fills in table names in a combo box, as shown in Figure 32.28(b). You can select a table from the combo box to display its contents in the text area.
[Page 1124]
 


Introduction to Java Programming-Comprehensive Version
Introduction to Java Programming-Comprehensive Version (6th Edition)
ISBN: B000ONFLUM
EAN: N/A
Year: 2004
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net