Assignment title: Information
Faculty of Science, Engineering and Technology
SWE80005 Enterprise Development [Java EE]
Pass Task 2.1 Programming with Database Connectivity using JDBC
Time Frame: Weeks 2 – 3
Suggested to start and complete in Week 2
Submission Due: Week 2, Fri, 5:00pm
Overview
In this task, you are required to program data access object that can access the content of a database table. You
are also required to demonstrate your work is of good quality.
Purpose To demonstrate your ability to develop quality application that connects to database
Tasks 1. Learn to write an application that can access the data stored in a database table
2. Extend the application developed in 1 above so that it can now handle all the actual
CRUD operations
3. Program a client application to test the program developed in 2 above
4. Prepare your test cases and test your application thoroughly by using various
database contents (e.g. different records)
5. Answer questions related to the design of the application
6. Submit the work for feedback
Pre-req Task1 Pass Task 1.1
Follow-up Task2 Pass Task 3.1
Suggested Time 1 hour if you know the stuff well
4 - 5 hours if you need to read the concepts and know how to establish database
connections
Resources Lecture 02 Database Connectivity; Java EE – JDBC
Feedback Ask your tutor for feedback
Next task Pass Task 3.1
Pass Task 2.1 Submission Details and Assessment Criteria
You must create your own document (pdf) in portrait mode3, which you will upload to Doubtfire, with the
following details:
• Your name and student id
• Your tutor's name
• Your own responses to the tasks according to the corresponding instructions (see below)
Tasks and Instructions
Task 1. Complete Lab_02_Database_Connectivity
Task 2. Add the following methods in the MyDB.java class in Lab_02_Database_Connectivity that supports the
CRUD operations of MYUSER using JDBC
1. "boolean createRecord(Myuser myuser)" – accepts a Myuser object and checks whether
the actual record exists in the database. If the record does not exist, it will create a new record in
MYUSER database with the information in the Myuser object and return true. Otherwise, it returns
false (and does not create the record).
1
You need to complete the pre-requisite task before doing this task.
2
You need to complete this task in order to do the follow-up task because the follow-up task depends on your
answer in this one.
3
Landscape mode pdf does not work properly in Doubtfire.Faculty of Science, Engineering and Technology SWE80005 Ent. Dev.
Pass Task 2.1
Page 2 of 2
2. "Myuser getRecord(String userId)" – accepts a String object whose value is the userId of
a record to be searched. If the record can be found, it returns a Myuser object that stores the
information of the actual database record. Otherwise, it returns a "null" object.
3. "boolean updateRecord(Myuser myuser)" – accepts a Myuser object and checks whether
the actual record exists in the database. If it does, it will update the information of the record with
the current information stored in the Myuser object and return true. Otherwise, it returns false
without doing anything.
4. "boolean deleteRecord(String userId)" – accepts a String object whose value is the
userId of a record to be deleted. If the record can be found, it removes the record in the database
and return true. Otherwise, it returns false.
Task 3. Develop a client program that requests the methods you developed in Task 2 as a test harness.
Note: The client program can be a desktop application (either console or with GUI). Console application
is the simplest. Or, it can be a web application (but this is too much work at the moment).
Task 4. Write your test cases (including the database content and input values) and test your work thoroughly.
Remember to collect the screen dump (e.g. "Console" in NetBeans or your "JUnit" test results)
Task 5. Answer the following question:
In this lab, all classes developed by you sit in one machine, but let us assume the following:
The client programs (SetUpMyUser.java and any other programs that you developed for requesting the CRUD
operations of Myuser DB table) sit on one machine (Machine A), MyDB sits on another machine (Machine B),
and the Java DB sits on a third machine (Machine C).
5.1. What is the role of the Myuser class? DAO / DTO / both? Justify your answer.
5.1.1. In case, the "Myuser" class is not a DAO. Then, it must be "MyDB" taking the role of a DAO. Why?
Justify your answer. [Hint: What constitutes a DAO? Is it just the name or the services it
provides?]
5.2. In Machine A, if a program (e.g. SetUpMyUser) calls "myuser.setName("ABC")", will this change
the corresponding value in the database server? Why or Why not?
5.3. In Machine B, if MyDB calls "myuser.setName("ABC")", will this change the corresponding value in
the database server? Why or Why not?
Task 6. [Submission Task] Once completed, you need to submit a pdf file that contains all your work (e.g. selected
code segments – show me the key stuff and some screen dumps of your testing)
Demonstration
You may be asked to demonstrate your assignment in the lab. You should be able to do this and explain your code
when asked in the lab session.