Dsa Project1
Dsa Project1
1. System Architecture:
Client-Server Model:
2. Database Design:
8. Security Measures:
Data Protection: Secure storage and transmission of data.
Customer Interface:
Queue Status Display:
Real-time updates on the customer's position in the
queue and estimated wait time.
Product Browsing:
Customers can browse available products, view
details, and add items to their orders.
Staff Interface:
Dashboard:
Staff can monitor queue status, customer flow, and
manage customer priorities.
Order Management:
Staff can view, update, or delete orders as needed.
Customer Management:
Staff can access customer information and assist with
inquiries.
Main Source Code:
package JDBC1;
import java.util.Scanner;
import JDBC1.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
}
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
}
switch(ch)
{
case 1:
i1.insert();
break;
case 2:
i2.insert();
break;
case 3:
s2.display();
i3.insert();
break;
case 4:
s1.display();
u1.updateName();
break;
case 5:
s1.display();
u1.updatePhoneNumber();
break;
case 6:
s2.display();
i2.updateProductName();
break;
case 7:
s2.display();
i2.updateProductPrice();
break;
case 8:
s2.display();
i2.updateProductStock();
break;
case 9:
s3.display();
i3.updateOrderType();
break;
case 10:
d1.delete();
break;
case 11:
d2.delete();
break;
case 12:
d3.delete();
break;
case 13:
s1.display();
break;
case 14:
s2.display();
break;
case 15:
s3.display();
break;
case 16:
billing();
break;
case 17:
try{
Connection
connection=DriverManager.getConnection(url,username, password);
Statement statement=connection.createStatement();
String sql="use supermarket";
statement.executeUpdate(sql);
String sql1 = "SELECT c.c_id, c.queue_no, p.p_id, o.o_id,
o.o_quantity, p.p_price, " +
"SUM(p.p_price * o.o_quantity) AS total " +
"FROM customer c " +
"JOIN orders o ON c.c_id = o.c_id " +
"JOIN product p ON o.p_id = p.p_id " +
"WHERE c.queue_no = (SELECT MIN(queue_no)
FROM customer WHERE queue_no > 0 AND p.p_stock>=o.o_quantity)
;" ;
ResultSet resultSet=statement.executeQuery(sql1);
System.out.println("c_id "+"o_id"+" o_quantity "+" p_price "+"
total ");
while(resultSet.next())
{
int c_id=resultSet.getInt("c_id");
int p_id=resultSet.getInt("p_id");
int o_id=resultSet.getInt("o_id");
int o_quantity=resultSet.getInt("o_quantity");
int p_price=resultSet.getInt("p_price");
int total=resultSet.getInt("total");
q1.add(new Inserting(c_id,p_id,o_id,o_quantity,p_price,total));
}
while(!q1.isEmpty())
{
Inserting ins=q1.poll();
InsertingUpdatingInProduct i4;
if(ins.c_id!=0)
{
System.out.println(ins.c_id+" "+ins.p_id+" "+"
"+ins.o_id+" "+ins.o_quantity+" "+ins.p_price+" "+ins.total+"
");
}
else
{
System.out.println("Stock unavailable..");
return;
}
i2.updateProductStock(ins.p_id,ins.o_quantity);
d3.delete(ins.c_id);
d1.delete(ins.c_id);
}
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
break;
default:
System.out.println("Exit....");
}
}
while(ch<=17);
}
}
Menu Of Program:
Scalability and Flexibility: The modular design of the system allows for
easy updates and the addition of new features as needed.
JDBC Driver:
The project uses the MySQL JDBC driver:
Class.forName("com.mysql.cj.jdbc.Driver");
Database URL:
The connection URL for the MySQL database is:
jdbc:mysql://localhost:3306/?user=root
This URL connects to a MySQL server running on localhost at
port 3306 using the root user.
Database Credentials:
o Username: root
o Password: root
Establishing Connection:
A connection to the database is established using:
Connection connection = DriverManager.getConnection(url, username,
password);
Creating a Statement:
After establishing a connection, a Statement object is created to execute SQL
queries:
Statement statement = connectioJDBC Driver:
The project uses the MySQL JDBC driver:
Class.forName("com.mysql.cj.jdbc.Driver");
Database URL:
The connection URL for the MySQL database is:
jdbc:mysql://localhost:3306/?user=root
This URL connects to a MySQL server running on localhost at port 3306 using
the root user.
Database Credentials:
Username: root
Password: root
Establishing Connection:
A connection to the database is established using:
Connection connection = DriverManager.getConnection(url, username, password);
Creating a Statement:
After establishing a connection, a Statement object is created to execute SQL queries:
Statement statement = connection.createStatement();
Error Handling:
SQL exceptions are handled using try-catch blocks:
catch(SQLException e) { System.out.println(e.getMessage()); }
n.createStatement();
Executing SQL Queries:
SQL commands can be executed using:
o executeUpdate() for updates (e.g., creating tables, inserting data):
statement.executeUpdate("CREATE DATABASE supermarket");
o executeQuery() for retrieving data:
ResultSet resultSet = statement.executeQuery("SELECT * FROM
customer");
Error Handling:
SQL exceptions are handled using try-catch blocks:
catch(SQLException e) { System.out.println(e.getMessage()); }
Thank You.