Professional Documents
Culture Documents
Java Individual
Java Individual
Bank Application
Report
Acknowledgements
I would like to acknowledge our subject instructor Mr. Kiran Rana Magar
for giving me the chance to create Bank application to manage customers
details of Bank. From this project I got chance to develop my skill on
database, java programming, research and decision making.
Contents
Acknowledgement
…………………………………………………………………………………………………………….2
Introduction
…………….....……………………………………………………………………………………………4
Objective
…………………………………………………………………………………………………………….4
What I did
…………..………………………………………………………………………………..……………….4
ER Diagram
…………..………………………………………………………………………………..……………….5
Screenshoot of
Database...................…….…………………………………………………………………………….......6
Screenshoot of code…………………………………………………………………………………...7-22
Screenshoot of Output………………………………………………………………………………..23-32
1. Introduction
Bank application project is a model application. Specific staff of bank can use this application to
perform simple banking operations using this application through computing devices. The system
helps Employee of bank to create accounts of customer, keep withdraw detail, and check balances
as well as search customers by account number of saving as well as salary account and display
detailed information about all customers.
2. Objectives
3. What I did
I conducted some requirement analysis after reviewing the provided scenario, and I discovered
that we needed to construct a banking application with capabilities like account creation, account
editing, money deposits, money withdrawals, and account balance checking. In order to manage
customer data, we need to interconnect the application with the database. I started the process by
creating an ER diagram first, then I created the database and wrote a java programmed in Visual
Studio Code based on it.
4. ER-Diagram
5. Database
Database Connection
package databaseconnection;
import java.sql.*;
public class DbConnection {
Connection con;
Statement st;
ResultSet rows;
int val;
public DbConnection() {
try {
String username = "root";
String password = "database2";
Class.forName("com.mysql.cj.jdbc.Driver");
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/bank", username,
password);
if (con != null) {
System.out.println("connected to bank database");
} else {
System.out.println("error connecting database");
}
st = con.createStatement();
}
catch (Exception e) {
e.printStackTrace();
}
}
public int manipulate(String query) {
try {
val = st.executeUpdate(query);
// con.close();
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return val;
}
public ResultSet retrive(String query) {
try {
rows = st.executeQuery(query);
// con.close();
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return rows;
}
// public static void main(String[] args) {
// new DbConnection();
// }
}
Output:
Customer Controller
package view;
import java.sql.ResultSet;
import databaseconnection.DbConnection;
import model.Account;
import model.Customer;
public class CustomerController {
DbConnection db;
public int createAccount(Customer customer) {
String query;
// Accountno,fName,lNname,Address,DOB,accType
query = "insert into customer
(Accountno,fName,lName,Address,DOB,accType,balance) values('" +
customer.getAccountno() + "','" +
customer.getFName() + "','" +
customer.getLName() + "','" +
customer.getAddress() + "','" +
customer.getDOB() + "','" +
customer.getAccType() + "','" +
customer.getBalance() + "');";
// query = "insert into
Customer(Accountno,fName,lNname,Address,DOB,accType)
// values (234,'Bijay','Bhandari','Kalimati','2001-8-23',2);";
db = new DbConnection();
return db.manipulate(query);
}
// Accountno,fName,lName,Address,DOB,accType,balance
public int Updatedetail(Customer customer, int Accountno) {
String query = "Update customer " +
"set fName='" + customer.getFName() + "'," +
"lName='" + customer.getLName() + "'," +
"Address='" + customer.getAddress() + "'," +
"DOB='" + customer.getDOB() + "'," +
"accType='" + customer.getAccType() + "'" +
System.out.println("Error" + ex);
}
String query1 = "Update customer set balance='" + nbalance +
"'Where Accountno ='" + Accountno + "';";
db = new DbConnection();
return db.manipulate(query1);
}
public int Withdraw(int Amount, int Accountno) {
// int balance=
String query = "select * from Customer where Accountno = '" +
Accountno + "';";
db = new DbConnection();
int balance = 0, nbalance = 0;
ResultSet rs = db.retrive(query);
try {
while (rs.next()) {
balance = rs.getInt("balance");
if (balance < Amount) {
return 3;
}
nbalance = balance - Amount;
}
} catch (Exception ex) {
System.out.println("Error" + ex);
}
String query1 = "Update customer set balance='" + nbalance +
"'Where Accountno ='" + Accountno + "';";
db = new DbConnection();
return db.manipulate(query1);
}
public int Entry(Account account) {
return 0;
}
}
Customer Model
package model;
//import javax.print.DocFlavor.STRING;
public class Customer {
// for select,update
Customer(int custId, int Accountno, String fName, String lName, String
address, String DOB, int accType,
int balance) {
this.CustId = custId;
this.fName = fName;
this.lName = lName;
this.Address = address;
this.DOB = DOB;
this.accType = accType;
this.balance = balance;
}
// for insert
public Customer(int Accountno, String fName, String lName, String address,
String DOB, int accType, int balance) {
this.Accountno = Accountno;
this.fName = fName;
this.lName = lName;
this.Address = address;
this.DOB = DOB;
this.accType = accType;
this.balance = balance;
// update
public Customer(String fName, String lName, String address, String DOB, int
accType) {
this.fName = fName;
this.lName = lName;
this.Address = address;
this.DOB = DOB;
this.accType = accType;
public Customer() {
}
/**
* @return int return the CustId
*/
public int getCustId() {
return CustId;
}
/**
* @param CustId the CustId to set
*/
public void setCustId(int CustId) {
this.CustId = CustId;
}
/**
* @return int return the Accountno
*/
public int getAccountno() {
return Accountno;
}
/**
* @param Accountno the Accountno to set
*/
public void setAccountno(int Accountno) {
this.Accountno = Accountno;
}
/**
* @return String return the fName
*/
public String getFName() {
return fName;
}
/**
* @param fName the fName to set
*/
public void setFName(String fName) {
this.fName = fName;
}
/**
* @return String return the lName
*/
public String getLName() {
return lName;
}
/**
* @param lName the lName to set
*/
public void setLName(String lName) {
this.lName = lName;
}
/**
* @return String return the Address
*/
public String getAddress() {
return Address;
}
/**
* @param Address the Address to set
*/
public void setAddress(String Address) {
this.Address = Address;
}
/**
* @return String return the DOB
*/
public String getDOB() {
return DOB;
}
/**
* @param DOB the DOB to set
*/
public void setDOB(String DOB) {
this.DOB = DOB;
}
/**
* @return int return the accType
*/
public int getAccType() {
return accType;
}
/**
* @param accType the accType to set
*/
public void setAccType(int accType) {
this.accType = accType;
}
/**
* @return int return the balance
*/
public int getBalance() {
return balance;
}
/**
* @param balance the balance to set
*/
public void setBalance(int balance) {
this.balance = balance;
}
Customer View
package view;
import java.sql.ResultSet;
import java.util.Scanner;
import databaseconnection.DbConnection;
import model.Customer;
int CustId;
int Accountno;
String fName;
String lName;
String Address;
String DOB;
int accType;
int balance;
int Amount;
System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=");
System.out.println(" ");
System.out.println("WHAT DO YOU WANT TO DO? CHOOSE ONE OPTION
PLEASE:");
int choice = sc.nextInt();
switch (choice) {
case 1:
System.out.println(" ");
System.out.println("*#*#*#*#*#*#* Create Account
*#*#*#*#*#*#*");
System.out.println(
"------------------------------------------------
----");
// Accountno,fName,lNname,Address,DOB,accType
System.out.println("Enter your Account Number:(EXACTLY 5
NUMBER):");
int Accountno = sc.nextInt();
if (insert > 0) {
System.out.println("Customer added successfully");
} else {
System.out.println("Error registering customer");
}
System.out.println(
"------------------------------------------------
----");
break;
case 2: {
System.out.println(
"------------------------------------------------
----");
if (customer2 != null) {
if (update > 0) {
System.out.println("Successful");
} else
System.out.println("not");
} else {
System.out.println("invalid account ");
}
System.out.println(
"------------------------------------------------
----");
break;
case 3: {
System.out.println("*#*#*#*#*#*#*Deposit
Money*#*#*#*#*#*#*");
System.out.println(
"------------------------------------------------
----");
if (customer2 != null) {
if (update > 0) {
System.out.println("Successful");
} else
System.out.println("not");
}
System.out.println(
"------------------------------------------------
----");
break;
}
case 4: {
System.out.println("*#*#*#*#*#*#*WithDraw
Money*#*#*#*#*#*#*");
System.out.println(
"------------------------------------------------
----");
System.out.println("FOR verification please Enter your
Account Number:(EXACTLY 5 NUMBER):");
Accountno = sc.nextInt();
if (customer2 != null) {
System.out.println("Enter Withdraw Ammount");
int Amount = sc.nextInt();
CustomerController controller3 = new
CustomerController();
int update = controller3.Withdraw(Amount, Accountno);
if (update > 0) {
System.out.println("Successful");
} else
System.out.println("not");
}
System.out.println(
"------------------------------------------------
----");
break;
}
case 5: {
System.out.println("*#*#*#*#*#*#*Check
Balance*#*#*#*#*#*#*");
System.out.println(
"------------------------------------------------
----");
if (customer2 != null) {
int cbalance = 0;
DbConnection db = new DbConnection();
ResultSet rs;
try {
while (rs.next()) {
cbalance = rs.getInt("balance");
}
} catch (Exception e) {
System.out.println(e);
}
}
System.out.println(
"------------------------------------------------
----");
break;
}
case 6: {
System.exit(1);
}
System.out.println("*-------Thank You-------*");
System.out.println("Do you want to continue?");
ch = sc.next().charAt(0);
} while (ch == 'y' || ch == 'Y');
}
Overall Output
Create Account
Edit Account
Deposit Money
Withdraw Money
Check Balance
Exit
AccountType Model
package model;
}
public void setCustId(int custId) {
CustId = custId;
}
AccountType Controller
package Controller;
import databaseconnection.DbConnection;
import model.Account;
DbConnection db;
db = new DbConnection();
return db.manipulate(query);
}
}
import java.util.Scanner;
import Controller.AccountController;
import model.Account;
Thank You