Data Access Object: A. Objective

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 11

MODULE 9

DATA ACCESS OBJECT

A. OBJECTIVE
Students master how JDBC work and the application of JDBC by DAO model.
B. BASIC THEORY
How java application that built can work by DBMS (Database Management System) use
JDBC (Java Database Connectivity) concept on java. The implementation of JDBC usage
in application will use DAO model that divide data accessing function from other
application (presentation and control function).
C. TOOLS
1. Computer.
2. NetBeans application
D. EXPERIMENT
WORK STEP
1. Create New Project named LatihanMateri3_NIM (example : LatihanMateri3_0123)

2. Create several Package in the project:


a. Package: Login
b. Package: FormUtama
c. Package: Petugas
d. Package: Buku
e. Package: peminjaman
f.

Package: pengambalian

g. Package: Laporan

3. Add two classes in Login package


a. ViewLogin Class: is a Jframe (use to create interface)

b. DAOLogin class: is DAO for login function (use to accessing DBMS)

4. Before do the work farther with DAO (in java application), prepare the database first.
5. Run the phpMyAdmin to create needed database:
perpustakaan_NIM (example : perpustakaan_0123)

6. In the database, first add to pengguna table, three columns

7. In pengguna table, add 4 records for example

8.

Next, back to java application, in viewLogin add object ass figure:

Change object property as figure:

So, the appearance change as fogure:

9. Next, in VIewLogin, switch to Source display

10. Declare an Object DAOLogin

11. Next, we are going to finish the program for DAOLogin


12. First step, work with JDBC is (1) define used JDBC driver.
In this step there are two stage (a) adding used JDBC driver file (b) applying the driver to
DriverManager.

Add program code as figure:

13. Second step, define connection address (URL, user, password)

14. Third and fourth steps, create method to connect to the server and create statement object

15. Fifth step, create login checking method

16. We save the fifth step for temporary DAO


17. Next add program code in ViewLogin class in construction, to open the connection

18. Next, add event listener in btnLogin, for Login checking

Add the program code

19. Try to run the program

20. Add program code in btnKeluar

You might also like