Skip to content

sarthaksaitwal/Bank-Management-System-using-java

Repository files navigation

🏦 Bank Management System

A comprehensive web-based Bank Management System built using Java, JDBC, Servlets, Spring Framework, JSP, and MySQL. This application provides complete banking operations with separate user and admin interfaces.

πŸ“‹ Table of Contents

✨ Features

User Module

  • βœ… User Registration and Login
  • βœ… View Account Details (Balance, Transactions)
  • βœ… Create New Bank Accounts (Savings, Current, Fixed Deposit)
  • βœ… Deposit Money
  • βœ… Withdraw Money
  • βœ… Fund Transfer Between Accounts
  • βœ… View Transaction History
  • βœ… Update Profile
  • βœ… Change Password

Admin Module

  • βœ… View All Customers
  • βœ… View All Accounts with Balances
  • βœ… Approve/Deactivate User Accounts
  • βœ… Remove User Accounts
  • βœ… View and Manage All Transactions
  • βœ… Admin Dashboard with Statistics

πŸ› οΈ Technology Stack

Technology Purpose
Java 11+ Core Programming Language
Spring Framework 5.3.30 Dependency Injection & MVC
Spring JDBC Template Database Operations
MySQL 8.0 Database Management
JSP & JSTL View Layer
Servlets Request Handling
Maven Build & Dependency Management
Apache Commons DBCP2 Connection Pooling

πŸ“ Project Structure

bank-management-system/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main/
β”‚   β”‚   β”œβ”€β”€ java/
β”‚   β”‚   β”‚   └── com/
β”‚   β”‚   β”‚       └── bank/
β”‚   β”‚   β”‚           β”œβ”€β”€ controller/
β”‚   β”‚   β”‚           β”‚   β”œβ”€β”€ UserController.java
β”‚   β”‚   β”‚           β”‚   β”œβ”€β”€ AccountController.java
β”‚   β”‚   β”‚           β”‚   └── AdminController.java
β”‚   β”‚   β”‚           β”œβ”€β”€ dao/
β”‚   β”‚   β”‚           β”‚   β”œβ”€β”€ UserDAO.java
β”‚   β”‚   β”‚           β”‚   β”œβ”€β”€ UserDAOImpl.java
β”‚   β”‚   β”‚           β”‚   β”œβ”€β”€ AccountDAO.java
β”‚   β”‚   β”‚           β”‚   β”œβ”€β”€ AccountDAOImpl.java
β”‚   β”‚   β”‚           β”‚   β”œβ”€β”€ TransactionDAO.java
β”‚   β”‚   β”‚           β”‚   └── TransactionDAOImpl.java
β”‚   β”‚   β”‚           β”œβ”€β”€ model/
β”‚   β”‚   β”‚           β”‚   β”œβ”€β”€ User.java
β”‚   β”‚   β”‚           β”‚   β”œβ”€β”€ Account.java
β”‚   β”‚   β”‚           β”‚   └── Transaction.java
β”‚   β”‚   β”‚           └── service/
β”‚   β”‚   β”‚               β”œβ”€β”€ UserService.java
β”‚   β”‚   β”‚               β”œβ”€β”€ UserServiceImpl.java
β”‚   β”‚   β”‚               β”œβ”€β”€ AccountService.java
β”‚   β”‚   β”‚               β”œβ”€β”€ AccountServiceImpl.java
β”‚   β”‚   β”‚               β”œβ”€β”€ TransactionService.java
β”‚   β”‚   β”‚               └── TransactionServiceImpl.java
β”‚   β”‚   β”œβ”€β”€ resources/
β”‚   β”‚   β”‚   └── database.properties
β”‚   β”‚   └── webapp/
β”‚   β”‚       └── WEB-INF/
β”‚   β”‚           β”œβ”€β”€ views/
β”‚   β”‚           β”‚   β”œβ”€β”€ login.jsp
β”‚   β”‚           β”‚   β”œβ”€β”€ register.jsp
β”‚   β”‚           β”‚   β”œβ”€β”€ dashboard.jsp
β”‚   β”‚           β”‚   β”œβ”€β”€ adminPanel.jsp
β”‚   β”‚           β”‚   β”œβ”€β”€ transactions.jsp
β”‚   β”‚           β”‚   └── ...
β”‚   β”‚           β”œβ”€β”€ applicationContext.xml
β”‚   β”‚           β”œβ”€β”€ dispatcher-servlet.xml
β”‚   β”‚           └── web.xml
β”œβ”€β”€ database/
β”‚   └── bank_schema.sql
└── pom.xml

πŸ—„οΈ Database Schema

Tables

1. users

Column Type Description
user_id INT (PK) Auto-increment user ID
name VARCHAR(100) User's full name
email VARCHAR(100) Unique email address
password VARCHAR(255) User password
role ENUM USER or ADMIN
created_at TIMESTAMP Registration timestamp
is_active BOOLEAN Account status

2. accounts

Column Type Description
account_id INT (PK) Auto-increment account ID
user_id INT (FK) Reference to users table
account_number VARCHAR(20) Unique account number
balance DECIMAL(15,2) Current balance
account_type ENUM SAVINGS, CURRENT, FIXED_DEPOSIT
created_at TIMESTAMP Account creation time
is_active BOOLEAN Account status

3. transactions

Column Type Description
transaction_id INT (PK) Auto-increment transaction ID
from_account INT (FK) Source account
to_account INT (FK) Destination account
amount DECIMAL(15,2) Transaction amount
type ENUM DEPOSIT, WITHDRAWAL, TRANSFER
description VARCHAR(255) Transaction description
date_time TIMESTAMP Transaction timestamp
status ENUM SUCCESS, FAILED, PENDING

πŸš€ Setup Instructions

Prerequisites

  • Java 11 or higher
  • Maven 3.6+
  • MySQL 8.0+
  • MySQL Workbench (for database management)
  • Apache Tomcat 9.0+

Quick Setup (Automated)

cd "d:\Java\Bank Management System"
setup.bat

This will automatically create the database, configure connection, test it, and build the project.

Manual Setup

Step 1: Setup Database in MySQL Workbench

  1. Open MySQL Workbench
  2. Connect to your local MySQL instance
  3. Go to File β†’ Open SQL Script
  4. Select: database/bank_schema.sql
  5. Click Execute (⚑ button)

OR run via command line:

mysql -u root -p < database/bank_schema.sql

πŸ“– Detailed Guide: See MYSQL_WORKBENCH_SETUP.md

Step 2: Verify Database

In MySQL Workbench, run:

USE bank_management_db;
SELECT * FROM users;  -- Should show 5 users
SELECT * FROM accounts;  -- Should show 5 accounts
SELECT * FROM transactions;  -- Should show 10 transactions

Step 3: Configure Database Connection

Edit src/main/resources/database.properties:

db.driver=com.mysql.cj.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/bank_management_db?useSSL=false&serverTimezone=UTC
db.username=root
db.password=YOUR_MYSQL_ROOT_PASSWORD  # ← Update this!

Step 4: Test Connection (Optional)

mvn clean compile
mvn exec:java -Dexec.mainClass="com.bank.util.DatabaseConnectionTest"

You should see: βœ… ALL TESTS PASSED!

Step 5: Build the Project

mvn clean install

Step 6: Deploy to Tomcat

  1. Copy target/bank-management-system.war
  2. Paste to Tomcat's webapps directory
  3. Start Tomcat server
  4. Access: http://localhost:8080/bank-management-system

πŸ“š Additional Setup Guides

πŸ” Default Login Credentials

Admin Account

User Account

Other Test Users

🌐 API Endpoints

Authentication

  • GET /login - Login page
  • POST /login - Process login
  • GET /register - Registration page
  • POST /register - Process registration
  • GET /logout - Logout

User Operations

  • GET /user/dashboard - User dashboard
  • GET /user/account/create - Create account form
  • POST /user/account/create - Process account creation
  • GET /user/account/deposit - Deposit form
  • POST /user/account/deposit - Process deposit
  • GET /user/account/withdraw - Withdrawal form
  • POST /user/account/withdraw - Process withdrawal
  • GET /user/account/transfer - Transfer form
  • POST /user/account/transfer - Process transfer
  • GET /user/transactions - View transaction history
  • GET /user/account/{accountId} - View account details

Admin Operations

  • GET /admin/dashboard - Admin dashboard
  • GET /admin/customers - View all customers
  • GET /admin/accounts - View all accounts
  • GET /admin/transactions - View all transactions
  • POST /admin/user/approve/{userId} - Approve user account
  • POST /admin/user/deactivate/{userId} - Deactivate user
  • POST /admin/user/delete/{userId} - Delete user
  • GET /admin/user/{userId} - View user details

🎨 Design Pattern

The application follows the MVC (Model-View-Controller) architecture:

  • Model: Java POJOs representing database entities
  • View: JSP pages for UI rendering
  • Controller: Spring MVC Controllers for request handling
  • DAO Layer: Data Access Objects for database operations
  • Service Layer: Business logic implementation

πŸ“¦ Dependencies

Key Maven dependencies:

  • Spring Framework (Core, Context, Web, MVC, JDBC)
  • MySQL Connector
  • Servlet API
  • JSP & JSTL
  • Apache Commons DBCP2
  • SLF4J (Logging)

πŸ”§ Configuration Files

web.xml

Configures:

  • Spring ContextLoaderListener
  • DispatcherServlet
  • Character encoding filter
  • Session timeout
  • Error pages

applicationContext.xml

Configures:

  • Component scanning
  • DataSource (Connection pool)
  • JdbcTemplate
  • Transaction manager

dispatcher-servlet.xml

Configures:

  • MVC annotation-driven
  • View resolver
  • Static resources
  • Controller scanning

🎯 Key Features Implementation

Dependency Injection

Spring Framework's IoC container manages all beans with @Autowired annotation.

Transaction Management

@Transactional annotation ensures ACID properties for banking operations.

Connection Pooling

Apache Commons DBCP2 provides efficient database connection management.

Security Considerations

  • Session-based authentication
  • Role-based access control (USER vs ADMIN)
  • Input validation

πŸ“ Additional JSP Pages

Additional JSP pages need to be created:

  • deposit.jsp - Deposit money form
  • withdraw.jsp - Withdraw money form
  • transfer.jsp - Transfer money form
  • transactions.jsp - Transaction history
  • account-details.jsp - Account detail view
  • profile.jsp - User profile
  • change-password.jsp - Change password form
  • create-account.jsp - Create account form
  • admin-customers.jsp - All customers view
  • admin-accounts.jsp - All accounts view
  • admin-transactions.jsp - All transactions view
  • admin-user-details.jsp - User detail view (admin)
  • error.jsp - Error page

πŸ› Troubleshooting

Common Issues:

  1. Database Connection Failed

    • Verify MySQL is running
    • Check database credentials in database.properties
    • Ensure database exists
  2. 404 Error

    • Verify Tomcat is running
    • Check WAR deployment
    • Verify context path
  3. Compile Errors

    • Run mvn clean install
    • Check Java version (11+)
    • Verify Maven dependencies

πŸš€ Future Enhancements

  • Email notifications
  • SMS alerts for transactions
  • Password encryption (BCrypt)
  • JWT-based authentication
  • REST API implementation
  • Mobile responsive design
  • Transaction reports (PDF/Excel)
  • Two-factor authentication
  • Loan management module
  • Credit card module

πŸ“„ License

This project is created for educational purposes.

πŸ‘₯ Contributors

  • Your Name - Initial work

πŸ“ž Support

For issues and queries, please create an issue in the repository.


Note: Remember to change default passwords and implement proper security measures before deploying to production!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published