Skip to content
Snippets Groups Projects
Commit 74a4202d authored by Gian Bustamante (gib650)'s avatar Gian Bustamante (gib650)
Browse files

Update QueueingApp/src/main/java/appQueue/CustomerQueue.java

parent 1590444e
No related branches found
No related tags found
8 merge requests!20Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!19Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!18Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!17Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!16Update QueueingApp/src/main/webapp/workerAddsCustomer.jsp,...,!14Update QueueingApp/src/main/webapp/workerLogin.jsp,...,!13all updates to MAIN,!12Walk through v2
......@@ -163,8 +163,44 @@ public final class CustomerQueue{
} catch (SQLException e) {
e.printStackTrace();
}
updateAvgTime();
updateQueue();
}
public static void updateAvgTime() {
try {
Connection connection = dao.createConnection();
//Update each position
Statement sta = connection.createStatement();
ResultSet res = sta.executeQuery("SELECT * FROM `registration`.`customers` ORDER BY `position`;" );
while(res.next()) {
//prepare the statement
String update_customer = "UPDATE registration.customers SET avgWaiting = ? WHERE email = ? ;";
PreparedStatement prepared_statement = connection.prepareStatement(update_customer);
//1st position customer should only have 5 mins of waiting time
if(Integer.parseInt(res.getString("position")) == 1) {
prepared_statement.setString(1, Integer.toString(5));
prepared_statement.setString(2, res.getString("email"));
} else {
Integer newAvgTime = 10 * Integer.parseInt(res.getString("position"));
prepared_statement.setString(1, Integer.toString(newAvgTime));
prepared_statement.setString(2, res.getString("email"));
}
//execute query
prepared_statement.executeUpdate();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void updateQueue() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment