Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Textbook Selling System - Complete & Ready!

βœ… Status: ALL DATA NOW STORED IN DATABASE

Date: 2025-12-18
Database: MySQL (book_selling_system)
Language: Java (Swing GUI)
IDE: NetBeans


🎯 What This System Does

A complete desktop application for buying and selling textbooks with:

  • User Registration & Login - Secure account management
  • Admin Panel - Add and manage books
  • Book Browsing - View all available books
  • Order System - Buy books with delivery address
  • Booking Management - Track all orders
  • Request System - Submit requests and complaints

Everything is saved to MySQL database - no data is lost!


πŸ—„οΈ Database Schema

5 Tables Created:

  1. account - User accounts (registration/login)
  2. admin_users - Admin accounts (default: Soumya/1234)
  3. books - Book inventory (new and old books)
  4. bookings - Book orders with delivery info
  5. requests - User requests and complaints

2 Views Created:

  1. vw_all_books - Books with user who added them
  2. vw_user_bookings - Complete booking information

πŸš€ Quick Start

Step 1: Setup Database

Option A - Automated (Recommended):

# Double-click this file:
setup_database.bat

Option B - MySQL Workbench:

  1. Open MySQL Workbench
  2. File β†’ Open SQL Script
  3. Select database_setup.sql
  4. Click Execute (⚑)

Option C - Command Line:

mysql -u root -p < database_setup.sql

Step 2: Verify Database

USE book_selling_system;
SHOW TABLES;
-- Should show 5 tables: account, admin_users, books, bookings, requests

Step 3: Configure MySQL Password (if needed)

If your MySQL has a password, update it in:

  • DatabaseConnection.java (line 20)
  • Create_ac.java (line 235)
  • Userlogin.java (line 137)
  • Add_new_books.java (line 260)
  • Add_old_books.java (line 260)

Change:

String password = "";

To:

String password = "your_mysql_password";

Step 4: Run Application

πŸš€ EASIEST WAY - Just double-click:

run.bat

Or use PowerShell:

.\run.ps1

Or use NetBeans:

  1. Open project in NetBeans
  2. Build Project (F11)
  3. Run Project (F6)

Or manual command:

# Compile
javac -cp "mysql-connector-java-8.0.18.jar" -d "build\classes" src\Textbook_selling_system\*.java

# Run
java -cp "build\classes;mysql-connector-java-8.0.18.jar" Textbook_selling_system.Main_screen

Note: The run.bat and run.ps1 scripts automatically compile and run with the MySQL driver included!


πŸ§ͺ Test the Application

Test Admin Features

  1. Click "Admin Login"
  2. Username: Soumya
  3. Password: 1234
  4. Try adding books (both new and old)
  5. View bookings

Test User Features

  1. Create a new account
  2. Login with your credentials
  3. Browse books
  4. Buy a book
  5. Submit a request

Verify in Database

-- Check users
SELECT * FROM account;

-- Check books
SELECT * FROM books;

-- Check bookings
SELECT * FROM vw_user_bookings;

-- Check requests
SELECT * FROM requests;

πŸ“ Project Structure

Textbook_selling_system/
β”œβ”€β”€ src/Textbook_selling_system/
β”‚   β”œβ”€β”€ DatabaseConnection.java      βœ… Database connection manager
β”‚   β”œβ”€β”€ Create_ac.java               βœ… User registration β†’ account table
β”‚   β”œβ”€β”€ Userlogin.java               βœ… User login ← account table
β”‚   β”œβ”€β”€ AdminLogin.java              βœ… Admin login ← admin_users table
β”‚   β”œβ”€β”€ Add_new_books.java           βœ… Add new books β†’ books table
β”‚   β”œβ”€β”€ Add_old_books.java           βœ… Add old books β†’ books table
β”‚   β”œβ”€β”€ BuyBooks.java                βœ… Browse books ← books table
β”‚   β”œβ”€β”€ Address.java                 βœ… Place order β†’ bookings table
β”‚   β”œβ”€β”€ Show_bookings.java           βœ… View orders ← bookings table
β”‚   β”œβ”€β”€ Request.java                 βœ… Submit request β†’ requests table
β”‚   β”œβ”€β”€ UserHost.java                βœ… User dashboard
β”‚   β”œβ”€β”€ AdminHost.java               βœ… Admin dashboard
β”‚   └── Main_screen.java             βœ… Main menu
β”œβ”€β”€ database_setup.sql               πŸ“„ Complete database schema
β”œβ”€β”€ quick_setup.sql                  πŸ“„ Quick reference queries
β”œβ”€β”€ setup_database.bat               πŸ“„ Automated setup script
β”œβ”€β”€ DATABASE_INTEGRATION_SUMMARY.md  πŸ“„ Complete implementation details
β”œβ”€β”€ COMPLETE_ANALYSIS.md             πŸ“„ Project analysis
β”œβ”€β”€ DATABASE_SETUP_README.md         πŸ“„ Setup instructions
β”œβ”€β”€ ERROR_FIXES_SUMMARY.md           πŸ“„ Previous fixes
└── README.md                        πŸ“„ This file

πŸ“Š Features & Database Integration

Feature Java File Database Table Status
User Registration Create_ac.java account βœ… Working
User Login Userlogin.java account βœ… Working
Admin Login AdminLogin.java admin_users βœ… Working
Add New Books Add_new_books.java books βœ… Working
Add Old Books Add_old_books.java books βœ… Working
Browse Books BuyBooks.java books βœ… Working
Place Order Address.java bookings βœ… Working
View Bookings Show_bookings.java bookings βœ… Working
Submit Request Request.java requests βœ… Working

ALL FEATURES HAVE COMPLETE DATABASE INTEGRATION!


πŸ” Default Credentials

Admin Account

  • Username: Soumya
  • Password: 1234

Sample User Accounts (from database_setup.sql)

  • Username: johndoe | Password: password123
  • Username: janesmith | Password: password456

πŸ“ Sample Data

The database includes sample data for testing:

  • 2 sample users (johndoe, janesmith)
  • 5 sample books (Computer, Physics, English, Maths, Chemistry)
  • 1 admin user (Soumya)

πŸ”§ What Was Fixed

Previously Working:

  • βœ… Database connection
  • βœ… User registration
  • βœ… User/Admin login
  • βœ… Add books (new and old)

Fixed Today:

  • βœ… BuyBooks.java - Now loads books from database (was hardcoded)
  • βœ… Address.java - Now saves bookings to database (was only showing message)
  • βœ… Show_bookings.java - Now loads bookings from database (was empty)
  • βœ… Request.java - Now saves requests to database (was fake ID)
  • βœ… database_setup.sql - Added requests table

πŸ“š Documentation Files

  1. README.md (this file) - Quick start guide
  2. DATABASE_INTEGRATION_SUMMARY.md - Complete implementation details
  3. COMPLETE_ANALYSIS.md - Project analysis and architecture
  4. DATABASE_SETUP_README.md - Detailed setup instructions
  5. ERROR_FIXES_SUMMARY.md - Previous error fixes

πŸ› Troubleshooting

Error: "Unknown database 'book_selling_system'"

  • Run database_setup.sql to create the database

Error: "Access denied for user 'root'@'localhost'"

  • Check MySQL username and password
  • Update password in Java files if needed

Error: "MySQL JDBC Driver not found"

  • Ensure mysql-connector-java-8.0.18.jar is in project libraries
  • NetBeans: Right-click project β†’ Properties β†’ Libraries β†’ Add JAR

Error: "Communications link failure"

  • Ensure MySQL server is running
  • Check MySQL is on port 3306

No books showing in BuyBooks

  • Add books using Admin panel
  • Or check if sample data was inserted: SELECT * FROM books;

No bookings showing

  • Place an order first
  • Or check database: SELECT * FROM bookings;

πŸŽ“ How to Use

As Admin:

  1. Login with Soumya/1234
  2. Click "Add New Books" or "Add Old Books"
  3. Fill in book details
  4. Click "Add" - book saved to database
  5. Click "Show Bookings" to see all orders

As User:

  1. Create account or login
  2. Click "Buy Books" to see all available books
  3. Select a book and click "Buy Selected Book"
  4. Fill in delivery address
  5. Click "Place Order" - order saved to database
  6. Click "Request" to submit requests

πŸ“ˆ Database Queries

View all books:

SELECT * FROM vw_all_books;

View all bookings:

SELECT * FROM vw_user_bookings;

View pending bookings:

SELECT * FROM vw_user_bookings WHERE status = 'Pending';

View all requests:

SELECT * FROM requests ORDER BY request_date DESC;

Count books by condition:

SELECT book_condition, COUNT(*) FROM books GROUP BY book_condition;

βœ… Verification Checklist

Before using the application, verify:

  • MySQL server is running
  • Database book_selling_system exists
  • All 5 tables exist (account, admin_users, books, bookings, requests)
  • Default admin user exists (Soumya/1234)
  • Sample data is inserted
  • MySQL password is configured (if needed)
  • JDBC driver is in project libraries
  • Project builds without errors

πŸŽ‰ Success Criteria

You'll know everything is working when:

  1. βœ… You can create a user account
  2. βœ… You can login as user
  3. βœ… You can login as admin (Soumya/1234)
  4. βœ… Admin can add books
  5. βœ… User can see books in BuyBooks
  6. βœ… User can place orders
  7. βœ… Admin can see bookings
  8. βœ… User can submit requests
  9. βœ… All data persists in database

Check database after each action to verify data is saved!


πŸš€ Future Enhancements (Optional)

  • Session management (pass user info between screens)
  • Password hashing (BCrypt)
  • Search and filter books
  • Update booking status
  • Email notifications
  • Sales reports
  • Book cover images
  • Payment integration

πŸ“ž Support

For issues:

  1. Check console output for errors
  2. Verify MySQL is running
  3. Check database credentials
  4. Review documentation files
  5. Test with sample data

πŸ“„ License

Educational project for learning Java Swing and MySQL integration.


🎊 CONGRATULATIONS! Your Textbook Selling System is complete and fully integrated with MySQL database!

All data is now properly stored, retrieved, and managed through the database. No more lost information or hardcoded data!

Start the application and test all features! πŸš€

About

Textbook_selling_system . java swing .database use store data

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages