Relative Content

Tag Archive for javamysqljdbcservlets

I cannot access the count(*) value from the ResultSet in MySQL prepareStatement in Java

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 […]