Review the code and test the application - create an


Review the code and test the application

1. Open the project named ch2l_ex2_ProductMaint that's in the ex_starts directory.

2. Open the DAOFactory class. Note that the getProductDAO method has been changed so this application uses the methods in the ProductDB class to work with the Derby database.

3. Open the ProductDB class and review its code. This is the code that's presented in this chapter.

4. Open the ProductMaintApp class and review its code. Then, run this application. It should work the same as it did earlier in this book, but now it stores the data in a Derby database.

Add a disconnect method to the ProductDB class

5. Add a public method to the ProductDB class named disconnect that shuts down the Derby database engine and returns a boolean value that indicates if the shutdown was successful.

6. Switch to the ProductMaintApp class and try to add a statement that calls the disconnect method from the ProductDB class when the application ends. Note that you can't access this method because it's being called from a static context.

7. Now, try to call the disconnect method from the ProductDAO object. This time, you won't be able to access this method because it isn't available from the ProductDAO interface.

8. Create an interface named EmbeddedDB and add a method named disconnect to it.

9. Modify the ProductDAO interface so it inherits the EmbeddedDB interface.

10. Modify the ProductMaintApp class so it calls the disconnect method from the ProductDAO object when the application ends. Then, test the application to make sure it works correctly.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Review the code and test the application - create an
Reference No:- TGS02387385

Now Priced at $10 (50% Discount)

Recommended (93%)

Rated (4.5/5)