This is a simple console-based Bookstore Management System built using Java. It uses JDBC to connect to an H2 database and perform basic CRUD (Create, Read, Update, Delete) operations on a books table.
- Add new books with name and price
- View all books
- Search for a book by ID
- Search for books by name (partial match)
- Update a book’s price by its name
- Delete a book by ID
- Java (JDK 8+)
- JDBC (Java Database Connectivity)
- H2 Database (Embedded)
- IntelliJ IDEA (for development)
- Maven (for dependency management)
pom.xml – Maven configuration file
src/main/java/bookstore/
DAO/
BookDAO.java – Interface defining book operations
BookDAOImpl.java – Implementation of the DAO interface
model/
Book.java – Book entity/model class
runner/
TestBookStore.java – Main class to run and test the application
util/
DBUtil.java – Utility class to manage the H2 database connection
-
Clone the repository: git clone https://github.com/DivyaMadane/Bookstore-java.git
-
Open the project in IntelliJ IDEA (or any IDE that supports Maven).
-
Run the
TestBookStoreclass from: src/main/java/bookstore/runner/TestBookStore.java -
Use the console menu to perform operations like inserting, viewing, updating, or deleting books.
The application uses H2 database. No setup is required. A connection is automatically established using:
DriverManager.getConnection("jdbc:h2:~/Desktop/h2", "sa", "");
You can change the path in DBUtil.java if needed.
CREATE TABLE books (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
price FLOAT
);