0% found this document useful (0 votes)
18 views40 pages

IDB Project Amiyanshu 2141019063

The document is an end-term project report for a course on Introduction to Databases, submitted by Amiyanshu Sahoo. It includes a Java program that implements a Banking Management System, allowing users to manage customer records, account details, and transactions. The program connects to a SQL Server database and provides various functionalities such as adding, deleting, and updating customer information.

Uploaded by

psaswat598
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)
18 views40 pages

IDB Project Amiyanshu 2141019063

The document is an end-term project report for a course on Introduction to Databases, submitted by Amiyanshu Sahoo. It includes a Java program that implements a Banking Management System, allowing users to manage customer records, account details, and transactions. The program connects to a SQL Server database and provides various functionalities such as adding, deleting, and updating customer information.

Uploaded by

psaswat598
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/ 40

End-Term Project Report

On
Introduction to Databases (CSE 3151)

Submitted by

Name: Amiyanshu Sahoo


Reg. No.: 2141019063
Branch: CSE
Semester: 6th
Section: K
Session: 2023-2024
Admission Batch: 2021

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

FACULTY OF ENGINEERING & TECHNOLOGY (ITER)

SIKSHA ‘O’ ANUSANDHAN DEEMED TO BE UNIVERSITY

BHUBANESWAR, ODISHA – 751030


import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.sql.*;

public class MyJdbcProject {

public static void main(String[] args) {

Connection con = null;

Statement stmt = null;

try {

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

String conurl =

"jdbc:sqlserver://172.17.144.108;databaseName=S1941012407";

con = DriverManager.getConnection(conurl, "S1941012407",

"Iter1234#");

System.out.println("Connection is established");

stmt = con.createStatement();

BufferedReader br = new BufferedReader(new

InputStreamReader(System.in));

int ch = 0;

do {

// Display the menu

System.out.println("\n\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 Record for any

attribute except Customer Number");

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.println("Enter your choice (1-9):");

// Accept user's choice

ch = Integer.parseInt(br.readLine());

switch (ch) {

case 1:

// Display customer records

String sqlstr = "select * from CUSTOMER";

ResultSet rs = stmt.executeQuery(sqlstr);

int a = 0;

while (rs.next()) {

System.out.print('\n' + rs.getString("CUST_NO") +

'\t');

System.out.print('\t' + rs.getString("NAME"));

System.out.print('\t' +

rs.getString("PHONE_NO"));

System.out.print('\t' + rs.getString("CITY"));

a++;
}

System.out.println();

System.out.println("The number of rows selected is "

+ a);

break;

case 2:

// Add customer record

// Accept input for each column from user

System.out.println("Enter cust_no: \t");

String cust_no = br.readLine();

System.out.println("Enter the name: \t");

String name = br.readLine();

System.out.println("Enter the phone: \t");

long phone = Long.parseLong(br.readLine());

System.out.println("Enter the city: \t");

String city = br.readLine();

String insertstmt = "insert into customer values('" +

cust_no + "','" + name + "','" + phone + "','" + city

+ "')";

int n = stmt.executeUpdate(insertstmt);

System.out.println(n + " Row Inserted");

break;

case 3:

// Delete customer record

System.out.println("Enter a cust_no for deletion:

\t");
String cust = br.readLine();

String deletestmt = "delete from customer where

cust_no='" + cust + "'";

n = stmt.executeUpdate(deletestmt);

System.out.println(n + " Row deleted");

break;

case 4:

// Update customer record

// Accept customer number from user

System.out.println("Enter Cust No");

cust_no = br.readLine();

System.out.println("Enter 1: For Name 2: For Phone no

3: For City to update:");

// Accept user's choice

int c1 = Integer.parseInt(br.readLine());

switch (c1) {

case 1:

// Update name of the customer

System.out.println("Enter updated name");

String updatedName = br.readLine();

String queryupdateName = "Update Customer set

Name = '" + updatedName + "' where Cust_no =

'" + cust_no + "'";

n = stmt.executeUpdate(queryupdateName);

System.out.println(n + " Updated

Successfully");
break;

case 2:

// Update customer's phone number

System.out.println("Enter updated Phone");

long updatedPhone =

Long.parseLong(br.readLine());

String queryupdatePhone = "Update Customer

set Phone_No = '" + updatedPhone + "' where

Cust_no = '" + cust_no + "'";

n = stmt.executeUpdate(queryupdatePhone);

System.out.println(n + " Updated

Successfully");

break;

case 3:

// Update customer's city

System.out.println("Enter updated City");

String updatedCity = br.readLine();

String queryupdateCity = "Update Customer set

City = '" + updatedCity + "' where Cust_no =

'" + cust_no + "'";

n = stmt.executeUpdate(queryupdateCity);

System.out.println(n + " Updated

Successfully");

break;

break;
case 5:

// Show account details of a customer

System.out.println("Enter Cust No");

cust_no = br.readLine();

String queryAccDetails = "SELECT A.ACCOUNT_NO,


A.TYPE, A.BALANCE, B.BRANCH_CODE, B.BRANCH_NAME, B.BRANCH_CITY FROM ACCOUNT
A, BRANCH B, CUSTOMER C, DEPOSITOR D WHERE D.ACCOUNT_NO = A.ACCOUNT_NO AND
A.BRANCH_CODE = B.BRANCH_CODE AND C.CUST_NO = D.CUST_NO AND C.CUST_NO = '" +
cust_no + "'";

rs = stmt.executeQuery(queryAccDetails);

System.out.format("Acc. No.: \tType: \tBalance:

\tBranch Code: \tBranch Name: \t\tBranch City:\n");

while (rs.next()) {

String account_no = rs.getString("ACCOUNT_NO");

String type = rs.getString("TYPE");

long balance = rs.getLong("BALANCE");

String branch_code = rs.getString("BRANCH_CODE");

String branch_name = rs.getString("BRANCH_NAME");

String branch_city = rs.getString("BRANCH_CITY");

System.out.format("%s \t\t%s \t %d\t\t %s\t\t

%s\t %s\t\n", account_no, type, balance,

branch_code, branch_name, branch_city);

break;

case 6:

// Show loan details of a customer

System.out.println("Enter Cust No");

cust_no = br.readLine();
String queryLoanDetails = "SELECT C.*, L.LOAN_NO,
L.AMOUNT, B.* FROM LOAN L, CUSTOMER C, BRANCH B WHERE L.BRANCH_CODE =
B.BRANCH_CODE AND C.CUST_NO = L.CUST_NO AND C.CUST_NO = '" + cust_no + "'";

rs = stmt.executeQuery(queryLoanDetails);

while (rs.next()) {

String ccust = rs.getString("CUST_NO");

String cname = rs.getString("NAME");

long cphone = rs.getLong("PHONE_NO");

String ccity = rs.getString("CITY");

String loan_no = rs.getString("LOAN_NO");

long amount = rs.getLong("AMOUNT");

String branch_code = rs.getString("BRANCH_CODE");

String branch_name = rs.getString("BRANCH_NAME");

String branch_city = rs.getString("BRANCH_CITY");

System.out.format("%s %s %d %s %s %d %s %s %s\n",

ccust, cname, cphone, ccity, loan_no, amount,

branch_code, branch_name, branch_city);

break;

case 7:

// Deposit money

System.out.println("Enter Account No");

String acc_no = br.readLine();

System.out.println("Enter the amount to deposit");

long amt = Long.parseLong(br.readLine());

String queryAddMoney = "Update ACCOUNT set BALANCE =

BALANCE + " + amt + " where ACCOUNT_NO = '" + acc_no

+ "'";
n = stmt.executeUpdate(queryAddMoney);

System.out.println(n + " Balance Updated");

break;

case 8:

// Withdraw money

System.out.println("Enter Account No");

acc_no = br.readLine();

System.out.println("Enter the amount to withdraw");

amt = Long.parseLong(br.readLine());

String queryCheckBalance = "Select BALANCE from

ACCOUNT where ACCOUNT_No = '" + acc_no + "'";

rs = stmt.executeQuery(queryCheckBalance);

while (rs.next()) {

long bal = rs.getLong(1);

if (amt <= bal) {

String querySubMoney = "Update ACCOUNT set

BALANCE = BALANCE - " + amt + " where

ACCOUNT_NO = '" + acc_no + "'";

n = stmt.executeUpdate(querySubMoney);

System.out.println(n + " Balance Updated");

} else {

System.out.println("Insufficient balance");

break;
case 9:

// Exit the menu

System.out.println("Visit us next time");

stmt.close();

con.close();

System.exit(0);

break;

default:

// Handle wrong choice of option

System.out.println("Enter from 1 to 9, nothing else.

Please try again.");

break;

} while (ch != 9);

} catch (Exception e) {

System.out.println(e);

}
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy