📚 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
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!
- account - User accounts (registration/login)
- admin_users - Admin accounts (default: Soumya/1234)
- books - Book inventory (new and old books)
- bookings - Book orders with delivery info
- requests - User requests and complaints
- vw_all_books - Books with user who added them
- vw_user_bookings - Complete booking information
Option A - Automated (Recommended):
# Double-click this file:
setup_database.bat
Option B - MySQL Workbench:
- Open MySQL Workbench
- File → Open SQL Script
- Select database_setup.sql
- Click Execute (⚡)
Option C - Command Line:
mysql -u root -p < database_setup.sql
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:
To:
String password = "your_mysql_password";
🚀 EASIEST WAY - Just double-click:
Or use PowerShell:
Or use NetBeans:
- Open project in NetBeans
- Build Project (F11)
- 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!
- Click "Admin Login"
- Username: Soumya
- Password: 1234
- Try adding books (both new and old)
- View bookings
- Create a new account
- Login with your credentials
- Browse books
- Buy a book
- Submit a request
-- Check users
SELECT * FROM account;
-- Check books
SELECT * FROM books;
-- Check bookings
SELECT * FROM vw_user_bookings;
-- Check requests
SELECT * FROM requests;
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!
- Username: Soumya
- Password: 1234
Sample User Accounts (from database_setup.sql)
- Username: johndoe | Password: password123
- Username: janesmith | Password: password456
The database includes sample data for testing:
- 2 sample users (johndoe, janesmith)
- 5 sample books (Computer, Physics, English, Maths, Chemistry)
- 1 admin user (Soumya)
- ✅ Database connection
- ✅ User registration
- ✅ User/Admin login
- ✅ Add books (new and old)
- ✅ 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
- README.md (this file) - Quick start guide
- DATABASE_INTEGRATION_SUMMARY.md - Complete implementation details
- COMPLETE_ANALYSIS.md - Project analysis and architecture
- DATABASE_SETUP_README.md - Detailed setup instructions
- ERROR_FIXES_SUMMARY.md - Previous error fixes
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;
- Place an order first
- Or check database: SELECT * FROM bookings;
- Login with Soumya/1234
- Click "Add New Books" or "Add Old Books"
- Fill in book details
- Click "Add" - book saved to database
- Click "Show Bookings" to see all orders
- Create account or login
- Click "Buy Books" to see all available books
- Select a book and click "Buy Selected Book"
- Fill in delivery address
- Click "Place Order" - order saved to database
- Click "Request" to submit requests
SELECT * FROM vw_all_books;
SELECT * FROM vw_user_bookings;
SELECT * FROM vw_user_bookings WHERE status = 'Pending';
SELECT * FROM requests ORDER BY request_date DESC;
Count books by condition:
SELECT book_condition, COUNT(*) FROM books GROUP BY book_condition;
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
You'll know everything is working when:
- ✅ You can create a user account
- ✅ You can login as user
- ✅ You can login as admin (Soumya/1234)
- ✅ Admin can add books
- ✅ User can see books in BuyBooks
- ✅ User can place orders
- ✅ Admin can see bookings
- ✅ User can submit requests
- ✅ 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
For issues:
- Check console output for errors
- Verify MySQL is running
- Check database credentials
- Review documentation files
- Test with sample data
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! 🚀