Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Bookstore Problem. Contents I.Problem Description II.Solution III.Exercise.

Similar presentations


Presentation on theme: "The Bookstore Problem. Contents I.Problem Description II.Solution III.Exercise."— Presentation transcript:

1 The Bookstore Problem

2 Contents I.Problem Description II.Solution III.Exercise

3 I. Problem Description ● Develop a GUI application that allows the user to – Search books if info about authors and publishers are given – Change prices of all books from a given publisher. Changing prices for all publishers at once is not allowed ● A sample GUI is given in the next slides

4

5

6 ● A book has – A title, – An ISBN (International Standard Book Number), – A price – Info about its publisher, – Info about its author(s) ● A publisher has a name, a URL, and a list of books ● An author has a name, consisting of first name and last name, and the author writes one or more books – In each book, the author has an order of writing

7 Ex 1: A book is written by one author ● Title: The Mythical Man-Month ● ISBN: 0-201-83595-9 ● Price: $29.95 ● Publisher – Name: Addison-Wesley – URL: www.aw-bc.comwww.aw-bc.com – Books:... ● Author – First name: Frederick P.; last name: Brooks – Order of authors: 1 – Books:...

8 Ex 2: A book is written by many authors ● Title: Design Patterns ● ISBN: 0-201-63361-2 ● Price: 54.99 ● Publisher – Name: Addison-Wesley – URL: www.aw-bc.comwww.aw-bc.com – Books:... ● Author – First name: Erich; last name: Gamma; Order of authors: 1 – First name: Richard; last name: Helm; Order of authors: 2 – First name: Ralph; last name: Johnson; Order of authors: 3 – First name: John; last name: Vlissides; Order of authors: 4

9 Ex 3: An author writes many books First name: Donald E.; last name: Knuth Order of authors : 1 Books – Title: The Art of Computer Programming vol. 1; ISBN: 0-201- 89683-4; Price: 59.99 – Title: The Art of Computer Programming vol. 2; ISBN: 0-201- 89684-2; Price: 59.99 – Title: The Art of Computer Programming vol. 3; ISBN: 0-201- 89685-0; Price: 59.99

10 II. Solution 1.The 3-Tier Software Architecture 2.Developing the Data Tier 3.Developing the View 4.Developing Java Code

11 1. The 3-Tier Software Architecture Presentation Tier Data Tier Business Logic Tier Java Swing Logical Code + Data Manager RDBMS Data Manager

12 2. Developing the Data Tier 2.1. The Object Model 2.2. The Database Model 2.3. Creating the Database 2.4. Creating the Java Project 2.5 Creating a Connection Profile 2.6. Creating and Running SQL Scripts

13 2.1. The Object Model

14 2.2. The Database Model

15 2.3. Creating the Database ● Database Name: BOOKSTORE

16 2.4. Creating the Java Project ● File > New Project... ● New Java Project: Bookstore

17 2.5 Creating a Connection Profile

18 2.6. Creating and Running SQL Scripts

19

20

21

22 3. Developing the View

23 4. Developing Java Code 4.1. Adding the JDBC Driver JAR File to the Project's Libraries 4.2. Creating the Database Configuration File 4.3. Managing the Database Connection 4.4. Declaring a Data Manager to Interact to the Data Tier 4.5. Adding Author' names to the Author Combo Box 4.6. Adding Data to the Publisher Combo Box 4.7. Developing Action for the Query Button 4.8. Developing Action for the Change prices Button

24 4.1. Copying the JDBC Driver JAR File to the Project Folder ● JAR File: mysql-connector-java-5.1.6-bin.jar ● In Eclipse – Create the lib folder: Right-click the project's root folder > New > Folder > Folder name: lib > Finish – Copy the JAR file to the lib folder – Right-click the JAR file > Build Path > Add to Build Path

25 4.2. Creating a Database Configuration File ● Right-click the project's root folder > New > File > File name: persistence.properties > Finish drivers=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/BOOKSTORE username=... password=...

26 4.3. Managing the Database Connection 4.3.1. Developing a Utility to Create and Close a Database Connection 4.3.2. Getting the Connection 4.3.3. Closing the Connection When the Frame is Closed

27 4.3.1. Developing a Utility to Create and Close a Database Connection

28

29 4.3.2. Getting the Connection

30 4.3.3. Closing the Connection When the Frame is Closed

31 4.4. Declaring a Data Manager to Interact to the Data Tier

32 4.5. Adding Authors' Names to the Author Combo Box

33

34

35 4.6. Adding Data to the Publisher Combo Box

36

37 4.7. Developing Action for the Query Button 4.7.1. Both Author and Publisher are “Any” 4.7.2. Author is Specific and Publisher is “Any” 4.7.3. Author is “Any” and Publisher is Specific 4.7.4. Both Author and Publisher are Specific

38 4.7.1. Both Author and Publisher are “Any”

39

40 4.7.2. Author is Specific and Publisher is “Any”

41

42 4.7.3. Author is “Any” and Publisher is Specific

43

44 4.7.4. Both Author and Publisher are Specific

45

46 4.8. Developing Action for the Change Prices Button

47

48 III. Exercise ● Improve the application so that it can change prices of all books from a given author and a given publisher


Download ppt "The Bookstore Problem. Contents I.Problem Description II.Solution III.Exercise."

Similar presentations


Ads by Google