PreparedStatement w =conn.prepareStatement("SELECT count(*) as total from waitingList where trainID = ? and routeID = ? and className = ? and dateOfJourney = ? and startTime = ?;");
w.setString(1,trainID);
w.setString(2, routeID);
w.setString(3, className);
w.setString(4, date);
w.setString(5, startTime);
ResultSet x = w.executeQuery();
x.next();
int waitingList = x.getInt("total");
System.out.println("WaitingList : "+waitingList);
This is the code and here is the output:
`WaitingList : 0`
I need to get the value of waitingList I have the value of this query as 2 when executing the command in mysql console;
New contributor
Madhavan T S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.