/** * This method is used to determine whether a user is over the limit of allowed consecutive reservations, * it gets the date from the current reservation's date and subtracts two days from it and then checks to * see if they have over the limit number of reservations in the database, if they do then it says that * they are over it returns true, if not then it returns false * @param con * @param username * @param id * @return boolean * @throws SQLException * @see com.xemoc.AdminServlet */ public boolean isOverMainLimit(Connection con, String username, String id) throws SQLException { boolean state = false; int i = Integer.parseInt(id); Statement st = con.createStatement(); Date d = getDateByID(con,id); GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTime(d); gc1.add(Calendar.DAY_OF_MONTH,2); Date d2 = gc1.getTime(); java.sql.Date d3 = new java.sql.Date(d.getTime()); java.sql.Date d4 = new java.sql.Date(d2.getTime()); ResultSet rs = st.executeQuery("SELECT count(*) FROM reservations WHERE username='"+username+"' and [date]=NOW() and [date] <= #"+d4+"#"); rs.next(); int num = rs.getInt(1); if(num <= getMainLimit(con)){ state = false; } else { state = true; } System.out.println(num); return state; } public boolean isOverDayLimit(Connection con, String username, String id) throws SQLException { boolean state = false; int i = Integer.parseInt(id); Statement st = con.createStatement(); Date d = getDateByID(con,id); java.sql.Date d2 = new java.sql.Date(d.getTime()); ResultSet rs = st.executeQuery("SELECT count(*) FROM reservations WHERE username='"+username+"' and date=#"+d2+"#"); rs.next(); int num = rs.getInt(1); if(num <= getDayLimit(con)){ state = false; } else { state = true; } System.out.println(num); return state; }