A user-friendly online bookstore web application built in Java. Users can register, browse and buy books, while administrators manage inventory and view sales history. This project demonstrates practical use of Java Servlets, JDBC, and MySQL in a real-world scenario.
Admin:
- Add, remove, and update book information
- Manage inventory and book prices
- View sales history
User:
- Register and log in
- Browse available books
- Select and purchase books
- Choose quantity for each book
- Receive purchase receipts
Layer | Technologies |
---|---|
Front-end | HTML, CSS, JavaScript, Bootstrap |
Back-end | Java (JDK 8+), Servlets, JDBC |
Database | MySQL |
Build/Deploy | Maven, Tomcat |
- Java JDK 8 or higher
- Apache Tomcat 8.0+
- Maven
- MySQL Server
- Git
- (Recommended) Eclipse EE or another Java IDE
- Launch MySQL Command Line or Workbench
- Create & Initialize the Database
create database if not exists onlinebookstore; use onlinebookstore; create table if not exists books( barcode varchar(100) primary key, name varchar(100), author varchar(100), price int, quantity int ); create table if not exists users( username varchar(100) primary key, password varchar(100), firstname varchar(100), lastname varchar(100), address text, phone varchar(100), mailid varchar(100), usertype int ); insert into books values('9780134190563','The Go Programming Language','Alan A. A. Donovan and Brian W. Kernighan',400,8); insert into books values('9780133053036','C++ Primer','Stanley Lippman and Josée Lajoie and Barbara Moo',976,13); insert into books values('9781718500457','The Rust Programming Language','Steve Klabnik and Carol Nichols',560,12); insert into books values('9781491910740','Head First Java','Kathy Sierra and Bert Bates and Trisha Gee',754,23); insert into books values('9781492056300','Fluent Python','Luciano Ramalho',1014,5); insert into books values('9781720043997','The Road to Learn React','Robin Wieruch',239,18); insert into books values('9780132350884','Clean Code','Robert C Martin',288,3); insert into books values('9780132181273','Domain-Driven Design','Eric Evans',560,28); insert into books values('9781951204006','A Programmers Guide to Computer Science','William Springer',188,4); insert into books values('9780316204552','The Soul of a New Machine','Tracy Kidder',293,30); insert into books values('9780132778046','Effective Java','Joshua Bloch',368,21); insert into books values('9781484255995','Practical Rust Projects','Shing Lyu',257,15); insert into users values('demo','demo','Demo','User','Demo Home','42502216225','[email protected]',2); insert into users values('Admin','Admin','Admin','User','Headquarters','9584552224521','[email protected]',1); insert into users values('user1','user1','User','One','Address 1','1236547089','[email protected]',2); commit;
-
Clone the repository
git clone YOUR_NEW_REPO_URL
-
Import project into Eclipse EE or your preferred IDE
-
Configure Database
- Edit
src/main/resources/application.properties
to match your MySQL DB username and password.
- Edit
-
Build with Maven
- Right-click project →
Run as > Maven build
(Goal:clean install
)
- Right-click project →
-
Set up Tomcat
- Right-click project →
Run as > Run on Server
- Choose Tomcat (v8.0 or higher); add the project to the server
- Right-click project →
-
Access the application
- Navigate to http://localhost:8083/onlinebookstore/ (or your selected port)
Role | Username | Password |
---|---|---|
Admin | Admin | Admin |
Demo | demo | demo |
User | user1 | user1 |
For security,displayed credentials are not being used in a live/production environment.
Q: Unable to connect to the database?
A: Check that MySQL is running, database details in application.properties
are correct, and rebuild with Maven. Restart Tomcat if necessary.
- This project is for educational and demonstration purposes. Security features are basic.
- Contributions and suggestions for further improvement are welcome — please open an Issue or Pull Request!
Maintained by: SahilSajwan
Contact: sahilsajwan26.com