Skip to content

notsushmit/banking-system-java-mysql

Repository files navigation

Banking System MVP - Java Swing + MySQL

A desktop banking application built with Java Swing and MySQL database connectivity. Successfully tested and working with MySQL 5.1.33.

βœ… Current Status

  • Application: Fully functional and tested
  • Database: Connected and working with MySQL 5.1.33
  • Authentication: Admin and user login working
  • Features: All banking operations implemented

Features

Admin Module

  • Admin login with username/password authentication
  • View and approve/reject pending user registrations
  • View all user accounts and balances
  • Manage loan requests (approve/reject with automatic balance updates)
  • Real-time data refresh capabilities
  • Tabbed interface for easy navigation

User Module

  • User registration with admin approval workflow
  • Secure user login (only approved users can access)
  • Deposit and withdraw money with balance validation
  • Real-time balance checking
  • Loan application system
  • Transaction logging with timestamp

Tech Stack

  • Frontend: Java Swing (GUI)
  • Backend: Core Java with JDBC
  • Database: MySQL 5.1.33 (compatible with older versions)
  • Database Driver: MySQL Connector/J 5.1.49 (optimized for MySQL 5.1.x)

πŸ“ Project Structure

banking-system-java-mysql/
β”œβ”€β”€ src/                              # Source code directory
β”‚   β”œβ”€β”€ Main.java                     # Application entry point & main menu
β”‚   β”œβ”€β”€ DBConnection.java             # Database connectivity & connection management
β”‚   β”œβ”€β”€ AdminLogin.java               # Admin authentication interface
β”‚   β”œβ”€β”€ AdminDashboard.java           # Admin management dashboard (tabs interface)
β”‚   β”œβ”€β”€ UserLogin.java                # User authentication & login interface
β”‚   β”œβ”€β”€ UserRegistration.java         # New user registration form
β”‚   β”œβ”€β”€ UserDashboard.java            # User banking operations interface
β”‚   β”œβ”€β”€ Transaction.java              # Transaction processing & database operations
β”‚   β”œβ”€β”€ Loan.java                     # Loan management & approval logic
β”‚   └── DemoDBConnection.java         # Demo database connection (alternative)
β”œβ”€β”€ lib/                              # External libraries
β”‚   └── mysql-connector-java-5.1.49.jar  # MySQL JDBC driver (compatible with 5.1.x)
β”œβ”€β”€ database_setup.sql                # Main database schema & table creation
β”œβ”€β”€ fix_mysql_auth.sql               # MySQL authentication fix script
β”œβ”€β”€ setup_database.bat               # Interactive database setup guide
β”œβ”€β”€ run.bat                          # Compile & run application script
β”œβ”€β”€ MYSQL_SETUP_GUIDE.md            # Comprehensive database setup guide
β”œβ”€β”€ MYSQL_TROUBLESHOOTING.md        # Common issues & solutions
β”œβ”€β”€ README.md                        # Project documentation (this file)
└── .gitignore                       # Git ignore rules

πŸ—οΈ Architecture Overview

  • Main.java: Entry point with main menu (Admin/User login options)
  • Authentication Layer: Separate login systems for admin and users
  • Admin Module: Complete user management, account approval, loan management
  • User Module: Registration, banking operations, loan applications
  • Database Layer: JDBC-based MySQL connectivity with transaction support
  • GUI Layer: Java Swing components with event-driven architecture

Prerequisites

  1. Java JDK 8 or higher
  2. MySQL Server 5.1.33 (or compatible version)
  3. MySQL Connector/J 5.1.49 (already included in lib/ folder)

πŸš€ Quick Start (Ready to Run!)

1. Database Setup

Option A: Using MySQL Command Line Client

  1. Open MySQL Command Line Client
  2. Enter your root password
  3. Copy and paste these commands:
CREATE DATABASE IF NOT EXISTS banking_system;
USE banking_system;

CREATE TABLE IF NOT EXISTS admin (
    admin_id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) NOT NULL,
    password VARCHAR(100) NOT NULL
);

INSERT INTO admin (username, password) VALUES ('admin', 'admin123');

CREATE TABLE IF NOT EXISTS users (
    user_id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    email VARCHAR(100) UNIQUE NOT NULL,
    password VARCHAR(100) NOT NULL,
    balance DOUBLE DEFAULT 0,
    status ENUM('Pending','Approved','Rejected') DEFAULT 'Pending'
);

CREATE TABLE IF NOT EXISTS transactions (
    txn_id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    type ENUM('Deposit','Withdraw') NOT NULL,
    amount DOUBLE NOT NULL,
    timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (user_id) REFERENCES users(user_id)
);

CREATE TABLE IF NOT EXISTS loans (
    loan_id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    amount DOUBLE NOT NULL,
    status ENUM('Pending','Approved','Rejected') DEFAULT 'Pending',
    request_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (user_id) REFERENCES users(user_id)
);

SHOW TABLES;

Option B: Import SQL File

mysql -u root -p < database_setup.sql

2. Update Database Password (if needed)

The application is configured for MySQL root password "123". If your password is different:

  1. Open src/DBConnection.java
  2. Update this line:
    private static final String PASSWORD = "your_mysql_password";

3. Run the Application

Option A: Using Batch File (Recommended)

# Double-click run.bat or execute:
run.bat

Option B: Manual Commands

# Compile
javac -cp "lib/mysql-connector-java-5.1.49.jar" src/*.java

# Run
java -cp "src;lib/mysql-connector-java-5.1.49.jar" Main

πŸ” Default Login Credentials

Admin Login

  • Username: admin
  • Password: admin123

Database Connection

  • Host: localhost:3306
  • Database: banking_system
  • Username: root
  • Password: 123 (update in DBConnection.java if different)

πŸ“– Usage Guide

Admin Workflow

  1. Login: Click "Admin Login" β†’ Enter admin credentials
  2. Approve Users: Go to "Pending Accounts" tab β†’ Select user β†’ Click "Approve"
  3. View All Users: Check "All Users" tab for complete user list
  4. Manage Loans: Use "Loan Requests" tab to approve/reject loan applications

User Workflow

  1. Register: Click "User Login" β†’ "Register" β†’ Fill details with initial deposit
  2. Wait for Approval: Admin must approve your account
  3. Login: Use email and password after approval
  4. Banking Operations:
    • Deposit: Add money to account
    • Withdraw: Remove money (with balance validation)
    • Check Balance: View current account balance
    • Apply for Loan: Submit loan requests for admin approval

πŸ—ƒοΈ Database Schema

Tables Created

  • admin: Admin credentials (1 default admin)
  • users: User accounts with approval status
  • transactions: All deposit/withdraw operations
  • loans: Loan applications and their status

πŸ”§ Technical Configuration

MySQL Compatibility

  • Tested with: MySQL 5.1.33-community
  • Driver: com.mysql.jdbc.Driver (legacy driver for older MySQL)
  • Connection URL: jdbc:mysql://localhost:3306/banking_system?useSSL=false&autoReconnect=true

Security Features

  • SQL injection prevention using PreparedStatements
  • Transaction rollback on database errors
  • Balance validation for withdrawals
  • Admin approval workflow for new accounts
  • Password-based authentication

πŸ› Troubleshooting

Application Won't Start

  • Check: MySQL service is running
  • Verify: Database password in src/DBConnection.java
  • Ensure: banking_system database exists

Connection Errors

  • "Access denied": Wrong MySQL password
  • "Unknown database": Run database setup commands
  • "Table doesn't exist": Execute CREATE TABLE commands

Common Solutions

  1. Restart MySQL service
  2. Verify database setup using MySQL Command Line Client
  3. Check password in DBConnection.java matches your MySQL root password

🎯 Testing Checklist

  • βœ… Application starts without errors
  • βœ… Admin login works (admin/admin123)
  • βœ… User registration creates pending accounts
  • βœ… Admin can approve/reject users
  • βœ… Approved users can login
  • βœ… Deposit/withdraw operations work
  • βœ… Loan applications and approvals function
  • βœ… Balance updates correctly
  • βœ… Transaction logging works

πŸš€ Future Enhancements

  • Password encryption (currently plain text)
  • Transaction history view for users
  • Email notifications for approvals
  • Interest calculation for loans
  • Account statements generation
  • Multi-currency support
  • User profile management

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published