Skip to content

vishalbharti585/JDBC-MySQL-ProductApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

🧩 CRUD Operations on Product Table Using JDBC

This project demonstrates how to use Java JDBC (Java Database Connectivity) to perform CRUD operations — Create, Read, Update, and Delete — on a Product table in a MySQL database.
It also implements transaction handling to maintain data integrity using setAutoCommit(false), commit(), and rollback().


🎯 Objective

To create a menu-driven Java program that performs all CRUD operations on a Product table in MySQL with proper transaction management and exception handling.


🧠 Concepts Covered

  • JDBC Driver (com.mysql.cj.jdbc.Driver)
  • Connection Management using DriverManager
  • PreparedStatement for parameterized queries (Prevents SQL Injection)
  • Transaction Handling (setAutoCommit(false), commit(), rollback())
  • Menu-driven console application
  • CRUD Operations (INSERT, SELECT, UPDATE, DELETE)

⚙️ Setup Instructions

1️⃣ Create Database and Table in MySQL

Run the following commands in MySQL Workbench or Command Line:

CREATE DATABASE shopdb;
USE shopdb;

CREATE TABLE Product (
    ProductID INT PRIMARY KEY,
    ProductName VARCHAR(50),
    Price DOUBLE,
    Quantity INT
);

INSERT INTO Product VALUES
(1, 'Laptop', 55000, 10),
(2, 'Smartphone', 25000, 20),
(3, 'Keyboard', 1200, 50);

Releases

No releases published

Packages

No packages published

Languages