A java application is one of the tools used by developers to design a functional
system to solve a given problem.
API: Application programming interface, is a given application to allow
communication with an external application, and those rules are set by devs
JDBC API: JDBC is a Java API providing a medium communication between java
appliaction and dbms
JDBC: Java Database Connectivity
CRUD: Create Read Update Delete
JDBC properties:
================
1. JDBC URL/URI
jdbc:mysql://localhost:3306/db_name
2. Database username
3. Database password
URL: https://www.AUCA.AC.rw:80/Index.html
===== ================ = ===========
protocol Domain name port file
number
JDBC URL: JDBC:DBMS://Localhost:portnumber/dbname.
127.0.0.1
steps for using JDCBC in Java
=============================
1. Load and Register Database driver
Class.forName("com.mysql.cj.jdbc.Driver)
2. Establish/ Create a connection
Connection con = DriverManager.getConnection(JDBC_URL,username,password);
3. Create statement
Statement st= con.createStatement();
4. Execute statement
String sql - "SELECT *FROM student";
CRUD:
>> st.execute(sql); --> CRUD(DML)/ DDL --> true/false
>>st.executeUpdate(sql); --> CUD --> int(Number of rows affected)
>>st.executeQuery(sql); --> Read Operation --> ResultSet
5. Close connection
con.close();
Loops in Java
-------------
1. For loop:
initialization: int i=0;
condition = i<10;
incrementation = i++;
=i+1'
//i+=1;
for(initionlization;condition;incrementation){
//statement
}
2. While(condition){
//statement
incrementation
}
3. do{
//statement
incrementation
}while (condition);
Scanner Utilization in Java
---------------------------
N.B:
1. import java.util.*;
2. import java.sql.*;
Scanner input = new Scanner(System.in);
Datatype:
int --> input.nextInt();
float --> input.nextFloat();
string--> input.next();
Presentation layer-> view:
------------------
CLI:
GUI: swing library
Business layer:
---------------
model:
=====
POJO(plain old java object)
implements data hiding,encapsulation concepts
- private variables
- contractor
- getter and setter
NB: -It should reflect database table
-Should have public as access modifier
A: constructor is a like a blueprint of a given java class
syntax: AccessModifier class
View:
=====
We provide an interface for End user to communicate with our application
controller:
===========
DAO: DAO stands for Data Access Object, it's used for separating Business Logic
layer and database layer, i.e: it's persistance logic is implemented!
helps to implement loose coupling concepts
NB:
1. each pojo class should have its own dao class
2. All JDBC implementation is done in dao class
persistance layer: DAO
database layer
software design pathern
MVC: Software design pattern used to apply separation concepts.
-model
-view:
-control
DAO: data access object
A. Swing Java API
-----------------
Java Swing API is one of the component rich with graphical component to be rendered
to end user.
Java swing those components are grouped together into java foundation classes
(JFC).
Java Swing is built on top of AWT (Abstract Window Toolkit).
Java swing holds component that are rich, lightweight , interdependent UI Component
Note:
=====
1. Rich Component means hold interactive components with look and feel feature
include, buttons, text area, dialogue, labels
Note: - In order to use swing component you add J on each component e.g: JButton,
JTextArea
-And those components are found under java swing package
2. lightweight: in terms of size it's less weight compared to AWT component which
makes it faster in performance
3. Indepedent UI component. It can run only on Java supporting environment
NB:
a. Swing is used to develop Desktop Application using Java
Software Validation Layers
==========================
1. Presentation Layer
2. Business Logic Layer
3. Database Layer
Why do we need to apply validation on system?
Providing exact input need by the system will process of those input data and
provide exactly needed response as output.
Possible Validation Rules that can be applied
---------------------------------------------
1. Make field required
2. Characted Length Validation
specify range of character allowed in the system , min and max character
3. Numerical range validation
specify on a given range of numbers
4. Regular Expression (Regex) validation
R[A-Z]{2}[0-9]{3}[A-Z]{1}
5.
RMI: REMOTE METHOD INVOCATION
-----------------------------
RMI is Java Technology sued to develop a distrubuted Java Application where we have
a server and client
Client Application it invokes/calls/disturb method hosted/ exposed by the server
In order Sever and Client to communicate they use gateway namely STUB and SKELETON
via network(internet)
Where Client use Stub and Server sue SKELETON as their gateway.
Server must be hoster either locally or publically
Proxy software design pattern
CLIENT SIDE METHOD INVOCATION PROCESS (STUB)
--------------------------------------------
1. Client establishes connection with server
2. Invokes method expose by server
3. It has to wait for a response from the server
4. It has to prove communation/ response to the client
SERVER SIDE METHOD INVOCATION PROCESS (SKELETON)
------------------------------------------------
1. Accepts connecting request from Client
2. It checks if method invoked exists
3. It processes the invoked method
4. It sends response to the client
Server side configuration
------------------------
0. import required libraries
1. Hibernate configuration
2. DAO implementation
3. Model Package with POJO must be created
4. Service package with service interface class holding Method signature of method
to be invoked by client
5. Implementation package for service interface
6. Server controller class (SKELETON)
NB:
a. POJO class should have Persistance Annotation and Implement Serializable
b.Each POJO class should have its own DAO class
c.Each POJO class should have its own service
d. Each service interface class must have its own implementation
e. Each service interface class must extend remote found from java.rmi.*;
f. Under Service Interface class method signature that throw RemoteException
g. Each Service implementation class must extend Unicast remote object and
implement its service interface class
Client Side Configuration
-------------------------
0. import required libraries
1. view package with SWING GUI forms
2. Model package witg POJO class that implement but without annotations
3. Service Package with Service Interface holding method needs to be invoked by the
client
In terms of what why and how, When do you have to use auto,identity,sequence and
table
*Generic class