Skip to content

PR-Pravin/java-user-authentication-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

🔐 User Authentication System — PN Solutions

A console-based User Authentication & Profile Management System built with Core Java and MySQL via JDBC. This project enables secure user registration, login, profile management, and account deletion — all through an interactive command-line interface.


🚀 Features

User Registration — New users can sign up with name, email, username, and password with data stored directly to MySQL.
Secure Login — Authenticates user credentials against the database using parameterized queries.
View Profile — Displays the logged-in user's complete profile details post-login.
Update Profile — Allows users to modify their name, email, username, and password.
Delete Account — Permanently removes user account with a confirmation prompt before deletion.
User Dashboard — Clean post-login menu to navigate all profile actions seamlessly.
Logout — Safely exits the current user session back to the home screen.


🛠️ Technologies Used

  • Java (JDK 8+): Core application logic, OOP design, and console I/O handling.
  • MySQL 8.x: Relational database for persistent user data storage.
  • JDBC: Java Database Connectivity using com.mysql.cj.jdbc.Driver for DB operations.
  • PreparedStatement: Parameterized SQL queries to prevent SQL injection.
  • OOP Design: Inheritance-based architecture — all DB classes extend DBconnection.

📂 Project Structure

  • HomePage.java — Entry point; displays main menu (Register / Login / Exit).
  • RegisterUser.java — Handles new user registration and inserts data into the database.
  • LoginPage.java — Authenticates credentials and launches the user dashboard on success.
  • Dashboard.java — Post-login hub for View, Update, Delete, and Logout operations.
  • updateProfile.java — Updates user profile fields in the database by username.
  • DeleteProfile.java — Deletes user account from the database with confirmation.
  • DBconnection.java — Base class providing reusable MySQL connection via JDBC.
  • query.sql — SQL script to create the user_db database and users table.

🗄️ Database Setup

Run the following SQL script in your MySQL client (also available in query.sql):

-- Create Database
CREATE DATABASE user_db;

-- Use Database
USE user_db;

-- Create Users Table
CREATE TABLE users (
    id         INT PRIMARY KEY AUTO_INCREMENT,
    name       VARCHAR(50)   NOT NULL,
    email      VARCHAR(100)  UNIQUE NOT NULL,
    username   VARCHAR(50)   UNIQUE NOT NULL,
    password   VARCHAR(100)  NOT NULL,
    created_at TIMESTAMP     DEFAULT CURRENT_TIMESTAMP
);

⚙️ Configuration

Open DBconnection.java and set your MySQL credentials:

private String url      = "jdbc:mysql://localhost:3306/user_db";
private String username = "your_mysql_username";
private String password = "your_mysql_password";

⚠️ Security Note: Never push real credentials to version control. Use environment variables or a config.properties file and add it to .gitignore.



🖥️ Application Flow

HomePage (Main Menu)
│
├── [1] Register ──────────► RegisterUser
│                                 └── Inserts into MySQL → Optional Login redirect
│
├── [2] Login ─────────────► LoginPage
│                                 └── Authenticates → Dashboard
│                                           ├── [1] View Profile
│                                           ├── [2] Update Profile ──► updateProfile
│                                           ├── [3] Delete Account ──► DeleteProfile
│                                           └── [4] Logout
│
└── [3] Exit

📖 Learning Outcomes

This project demonstrates proficiency in:

  • Java OOP principles — inheritance, encapsulation, and class design.
  • JDBC connectivity — establishing and managing MySQL connections from Java.
  • CRUD operations — Create, Read, Update, Delete via SQL with PreparedStatements.
  • Console-based UI design — building interactive menu-driven applications.
  • Database schema design — relational table creation with constraints and timestamps.

👤 Author

Pravin PR
🏢 PN Solutions
📍 Tamil Nadu, India


💡 This project is built for educational purposes to demonstrate Java-MySQL integration using JDBC. For production use, implement password hashing (BCrypt), input validation, and secure credential management.

About

A console-based User Authentication System built with Core Java, JDBC, and MySQL featuring registration, login, profile management, and account deletion.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages