0% found this document useful (0 votes)
7 views13 pages

Idb Project End Term

The document is an end-term project report for a course on databases, detailing a Banking Management System implemented in Java. It includes functionalities such as showing, adding, deleting, and updating customer records, as well as managing account and loan details. The output section summarizes test case results demonstrating the system's operations and responses to user inputs.

Uploaded by

reeth66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views13 pages

Idb Project End Term

The document is an end-term project report for a course on databases, detailing a Banking Management System implemented in Java. It includes functionalities such as showing, adding, deleting, and updating customer records, as well as managing account and loan details. The output section summarizes test case results demonstrating the system's operations and responses to user inputs.

Uploaded by

reeth66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

End Term Project Report

On
Introduction to Databases (CSE 3151)

Submitted by

Name :
Reg. No. :
Branch :
Semester :
Section :
Session : 2024-2025
Admission Batch : 2022

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


FACULTY OF ENGINEERING & TECHNOLOGY (ITER)
SIKSHA ‘O’ ANUSANDHAN DEEMED TO BE UNIVERSITY
BHUBANESWAR, ODISHA – 751030
BANKING MANAGEMENT SYSTEM:
CODE:
import java.sql.*;
import java.io.*;
import java.util.Scanner;
public class BankingManagementSystem {
public static void main(String[] args) throws IOException {
Connection con = null;
Statement stmt = null;
PreparedStatement pstmt = null;
Scanner sc = new Scanner(System.in);
try {
// Load Oracle JDBC Driver
Class.forName("oracle.jdbc.driver.OracleDriver");
// Connect to Oracle DB
String conurl = "jdbc:oracle:thin:@172.17.144.110:1521:ora11g";
con = DriverManager.getConnection(conurl, "your_user_id",
"your_password");
stmt = con.createStatement();
int choice;
do {
System.out.println("\n***** Banking Management System *****");
System.out.println("1. Show Customer Records");
System.out.println("2. Add Customer Record");
System.out.println("3. Delete Customer Record");
System.out.println("4. Update Customer Information");
System.out.println("5. Show Account Details of a Customer");
System.out.println("6. Show Loan Details of a Customer");
System.out.println("7. Deposit Money to an Account");
System.out.println("8. Withdraw Money from an Account");
System.out.println("9. Exit the Program");
System.out.print("Enter your choice: ");
choice = Integer.parseInt(sc.nextLine());
switch (choice) {
case 1:
ResultSet rs1 = stmt.executeQuery("SELECT * FROM customer");
System.out.println("CustNo\tName\t\tPhone\t\tCity");
while (rs1.next()) {
System.out.printf("%s\t%s\t%s\t%s\n",
rs1.getString(1), rs1.getString(2),
rs1.getString(3), rs1.getString(4));
}
break;
case 2:
System.out.print("Enter Customer No: ");
String custNo = sc.nextLine();
System.out.print("Enter Name: ");
String name = sc.nextLine();
System.out.print("Enter Phone No: ");
String phone = sc.nextLine();
System.out.print("Enter City: ");
String city = sc.nextLine();
pstmt = con.prepareStatement("INSERT INTO customer VALUES
(?, ?, ?, ?)");
pstmt.setString(1, custNo);
pstmt.setString(2, name);
pstmt.setString(3, phone);
pstmt.setString(4, city);
pstmt.executeUpdate();
System.out.println("Customer added successfully.");
break;
case 3:
System.out.print("Enter Customer No to Delete: ");
custNo = sc.nextLine();
pstmt = con.prepareStatement("DELETE FROM customer WHERE
cust_no = ?");
pstmt.setString(1, custNo);
int rows = pstmt.executeUpdate();
if (rows > 0) System.out.println("Customer deleted.");
else System.out.println("Customer not found.");
break;
case 4:
System.out.print("Enter Customer No to Update: ");
custNo = sc.nextLine();
System.out.println("1. Update Name");
System.out.println("2. Update Phone No");
System.out.println("3. Update City");
System.out.print("Enter choice: ");
int subChoice = Integer.parseInt(sc.nextLine());
String query = "";
switch (subChoice) {
case 1:
System.out.print("Enter new name: ");
name = sc.nextLine();
query = "UPDATE customer SET name = ? WHERE cust_no =
?";
pstmt = con.prepareStatement(query);
pstmt.setString(1, name);
break;
case 2:
System.out.print("Enter new phone: ");
phone = sc.nextLine();
query = "UPDATE customer SET phoneno = ? WHERE cust_no
= ?";
pstmt = con.prepareStatement(query);
pstmt.setString(1, phone);
break;
case 3:
System.out.print("Enter new city: ");
city = sc.nextLine();
query = "UPDATE customer SET city = ? WHERE cust_no = ?";
pstmt = con.prepareStatement(query);
pstmt.setString(1, city);
break;
}
pstmt.setString(2, custNo);
pstmt.executeUpdate();
System.out.println("Customer information updated.");
break;
case 5:
System.out.print("Enter Customer No: ");
custNo = sc.nextLine();
rs1 = stmt.executeQuery("SELECT c.cust_no, c.name,
a.account_no, a.type, a.balance, b.branch_code, b.branch_name, b.branch_city
FROM customer c, account a, branch b WHERE c.cust_no = a.cust_no AND
a.branch_code = b.branch_code AND c.cust_no = '" + custNo + "'");
while (rs1.next()) {
System.out.printf("CustNo: %s, Name: %s, AccNo: %s, Type: %s,
Balance: %.2f, Branch: %s, %s, %s\n",
rs1.getString(1), rs1.getString(2), rs1.getString(3),
rs1.getString(4), rs1.getDouble(5), rs1.getString(6),
rs1.getString(7), rs1.getString(8));
}
break;
case 6:
System.out.print("Enter Customer No: ");
custNo = sc.nextLine();
rs1 = stmt.executeQuery("SELECT c.cust_no, c.name, l.loan_no,
l.amount, b.branch_code, b.branch_name, b.branch_city FROM customer c,
loan l, branch b WHERE c.cust_no = l.cust_no AND l.branch_code =
b.branch_code AND c.cust_no = '" + custNo + "'");
if (!rs1.isBeforeFirst()) {
System.out.println("No loans for this customer.");
} else {
while (rs1.next()) {
System.out.printf("CustNo: %s, Name: %s, LoanNo: %s,
Amount: %.2f, Branch: %s, %s, %s\n",
rs1.getString(1), rs1.getString(2), rs1.getString(3),
rs1.getDouble(4), rs1.getString(5),
rs1.getString(6), rs1.getString(7));
}
}
break;
case 7:
System.out.print("Enter Account No: ");
String accNo = sc.nextLine();
System.out.print("Enter amount to deposit: ");
double deposit = Double.parseDouble(sc.nextLine());
pstmt = con.prepareStatement("UPDATE account SET balance =
balance + ? WHERE account_no = ?");
pstmt.setDouble(1, deposit);
pstmt.setString(2, accNo);
pstmt.executeUpdate();
System.out.println("Deposit successful.");
break;
case 8:
System.out.print("Enter Account No: ");
accNo = sc.nextLine();
System.out.print("Enter amount to withdraw: ");
double withdraw = Double.parseDouble(sc.nextLine());
rs1 = stmt.executeQuery("SELECT balance FROM account WHERE
account_no = '" + accNo + "'");
if (rs1.next()) {
double bal = rs1.getDouble(1);
if (bal >= withdraw) {
pstmt = con.prepareStatement("UPDATE account SET balance
= balance - ? WHERE account_no = ?");
pstmt.setDouble(1, withdraw);
pstmt.setString(2, accNo);
pstmt.executeUpdate();
System.out.println("Withdrawal successful.");
} else {
System.out.println("Insufficient balance.");
}
} else {
System.out.println("Account not found.");
}
break;
case 9:
System.out.println("Exiting program.");
break;
default:
System.out.println("Invalid choice.");
}
} while (choice != 9);

} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
} finally {
try {
if (stmt != null) stmt.close();
if (con != null) con.close();
} catch (Exception e) {
System.out.println("Error in closing: " + e.getMessage());
}
}
}
}
OUTPUT:
# -------------------------
# Test Case Outputs Summary
# Banking Management System
# -------------------------

# 1. Show Customer Records


CustNo Name Phone City
C0011 ANWESHA DAS 9999999999 BHUB
C0012 SACHIN SINGH 9898989898 CTC
C0013 ARJUN MISHRA 7777777777 BBSR

# 2. Add Customer Record


> Enter Customer No: C0014
> Enter Name: RAVI KUMAR
> Enter Phone No: 8888888888
> Enter City: RKL
Customer added successfully.

CustNo Name Phone City


C0011 ANWESHA DAS 9999999999 BHUB
C0012 SACHIN SINGH 9898989898 CTC
C0013 ARJUN MISHRA 7777777777 BBSR
C0014 RAVI KUMAR 8888888888 RKL
# 3. Delete Customer Record
> Enter Customer No to Delete: C0013
Customer deleted.

CustNo Name Phone City


C0011 ANWESHA DAS 9999999999 BHUB
C0012 SACHIN SINGH 9898989898 CTC
C0014 RAVI KUMAR 8888888888 RKL

> Enter Customer No to Delete: C0016


Customer not found.

# 4. Update Customer Record


> Enter Customer No to Update: C0011
> Enter choice: 1
> Enter new name: ANWESHA PATNAIK
Customer information updated.

CustNo Name Phone City


C0011 ANWESHA PATNAIK 9999999999 BHUB

# 5. Show Account Details


> Enter Customer No: C0003
CustNo: C0003, Name: SURAJ NAYAK, AccNo: A0008, Type: Savings, Balance:
15000.00, Branch: B001, MAIN, BBSR
> Enter Customer No: C0016
(no output)

# 6. Show Loan Details


> Enter Customer No: C0003
CustNo: C0003, Name: SURAJ NAYAK, LoanNo: L0001, Amount: 50000.00,
Branch: B001, MAIN, BBSR

> Enter Customer No: C0016


No loans for this customer.

# 7. Deposit to Account
> Enter Account No: A0008
> Enter amount to deposit: 800
Deposit successful.

Balance: 15800.00

# 8. Withdraw from Account


> Enter Account No: A0008
> Enter amount to withdraw: 800
Withdrawal successful.

Balance: 15000.00
> Enter Account No: A0008
> Enter amount to withdraw: 8000
Insufficient balance.

# 9. Exit
Exiting program.

# 10. Invalid Option


Invalid choice.

You might also like