A Java Swing desktop application for managing a medical store — patients, medicines, doctors, prescriptions, and billing — backed by a MySQL database.
| Module | What it does |
|---|---|
| Login | Username/password authentication against the database |
| Medicine Inventory | Add medicines with name, quantity, expiry date, cost; view/search stock |
| Patient Management | Register new patients; look up patients by phone with live autocomplete |
| Doctor Management | Add, view, and delete doctors; IDs auto-assigned |
| Issue Medicine | Select patient (phone autocomplete) + doctor (ID autocomplete) → add medicines → generate prescription |
| Billing | Auto-calculates total, deducts stock, saves bill with full DB transaction + rollback on error |
| Records | View last 10 transactions with patient, doctor, medicines, total, and timestamp |
- Language: Java (JDK 8+)
- UI: Java Swing
- Database: MySQL 8.0
- JDBC Driver:
mysql-connector-j-9.1.0.jar - Build: Plain
javac(no Maven/Gradle)
Medical_Store/
├── src/ # Java source files
│ ├── App.java # Entry point
│ ├── DatabaseConnection.java # DB connection + auto schema creation
│ ├── Login.java
│ ├── Home.java # Dashboard (Medicine, Patient, Doctor, Record)
│ ├── MedicineInventory.java
│ ├── AddMedicine.java
│ ├── StockInfo.java
│ ├── PatientInfo.java
│ ├── NewPatient.java
│ ├── PatientDetails.java # Phone autocomplete dropdown
│ ├── IssueMedicine.java # Phone + Doctor ID autocomplete dropdowns
│ ├── BillPopup.java
│ ├── DoctorInfo.java # Add / view / delete doctors
│ └── RecordPage.java
├── bin/ # Compiled .class files (git-ignored)
├── lib/
│ └── mysql-connector-j-9.1.0.jar
├── icons/ # UI background and button images
├── .env # DB credentials (git-ignored)
├── .env.example # Template for new setups
├── .gitignore
└── README.md
The schema is created automatically on first run — no manual SQL needed.
login (username PK, password_hash)
Doctor (doctor_id PK AUTO_INCREMENT, name)
Patient (patient_id PK, name, age, gender, phone UNIQUE, blood_group, address)
Medicine (medicine_id PK, name UNIQUE, stock_quantity, expiry_date, cost_per_unit)
Prescription (prescription_id PK, doctor_id FK, patient_id FK, medication TEXT, date_created)
Bill (bill_id PK, prescription_id FK, patient_id FK, total_amount, date_issued)
- Java JDK 8 or higher
- MySQL 8.0 running locally
git clone <repo-url>
cd Medical_StoreCopy the example env file and fill in your MySQL details:
cp .env.example .envEdit .env:
DB_HOST=localhost
DB_PORT=3306
DB_NAME=medicine_store1
DB_USER=root
DB_PASSWORD=your_password
If your MySQL service runs on a non-standard port (e.g.
3307), updateDB_PORTaccordingly.
javac -cp "lib/mysql-connector-j-9.1.0.jar" -d bin src/*.javajava -cp "bin;lib/mysql-connector-j-9.1.0.jar" AppImportant: Run from the project root directory so the app can find
.envand theicons/folder.
On first run, the app automatically:
- Creates the
medicine_store1database - Creates all 6 tables
- Seeds a default login (
admin/admin) and a default doctor (Dr. Sharma)
| Username | Password |
|---|---|
admin |
admin |
Change this directly in the login table after first login.
- Click Doctor on the Home screen
- Type the doctor's name and press Add Doctor or hit Enter
- The assigned Doctor ID appears in the table — use it when issuing medicine
- Home → Medicine → Add Medicine
- Fill in name, quantity, expiry date (YYYY-MM-DD), and cost per unit
- Re-submitting an existing medicine name updates its stock and details
- Home → Patient → New Patient
- Fill all fields — phone must be exactly 10 digits
- Home → Patient → Issue Medicine
- Type the patient's phone — a dropdown shows matching numbers; select to auto-fill the patient name
- Type the doctor ID — a dropdown shows matching doctors (
ID - Nameformat) - Select a medicine from the dropdown, enter quantity, click Add Medicine
- Repeat for multiple medicines, then click Generate Bill
- Home → Patient → About Patient
- Type partial phone number — dropdown shows all matching patients; click to load details
- Home → Record
- Shows the last 10 bills with full details
| Variable | Description | Default |
|---|---|---|
DB_HOST |
MySQL host | localhost |
DB_PORT |
MySQL port | 3306 |
DB_NAME |
Database name | medicine_store1 |
DB_USER |
MySQL username | root |
DB_PASSWORD |
MySQL password | (empty) |
.envis git-ignored — never commit credentialsbin/is git-ignored — compile locally after cloning- The MySQL JDBC driver (
lib/mysql-connector-j-9.1.0.jar) is included in the repo - Billing uses a DB transaction with full rollback if any medicine has insufficient stock
- Deleting a doctor who has existing prescriptions will fail with a clear error (foreign key constraint)

