<%java.util.Properties parms = new java.util.Properties(); parms.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory"); Context ctx = new javax.naming.InitialContext(parms); DataSource ds = (javax.sql.DataSource) ctx.lookup("jdbc/STAFFDBS"); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); //String sql = "select date,purpose,status,rid from room_booking where DATE(date) > DATE(CURRENT TIMESTAMP)"; //String sql = "select a.date,b.time,b.rbid from time_slot from room_booking a,time_slot b where a.rbid = b.rbid "; //String sql = "select a.date,b.name,a.purpose,a.status,a.emid,c.time from room_booking a, room b, time_slot c where a.rid = where a.rid = b.rid and a.rbid = c.rbid and status = 'Taken' and orderby date desc"; String sql = "select a.date,b.name,a.purpose,a.status,a.emid,c.time from room_booking a, room b, time_slot c where a.rid = b.rid and a.rbid=c.rbid and status = 'Taken' order by date asc "; ResultSet rs = stmt.executeQuery(sql); String date; String name; String purpose; String status; String emid; String time; Vector records = new Vector(); while (rs.next()){ date = rs.getString("date"); name = rs.getString("name"); purpose = rs.getString("purpose"); status = rs.getString("status"); emid = rs.getString("emid"); time = rs.getString("time"); try{ if(eform.util.Util.getCompareResult1 (date )> 0 ){ //we are only adding to the records if date > today JoRoomBookingBean bean = new JoRoomBookingBean(); bean.setDate(date); bean.setName(name); bean.setPurpose(purpose); bean.setStatus(status); bean.setEmid(emid); bean.setTime(time); records.addElement(bean); } }catch(Exception e){ System.out.println("An exception occured :"+e.getMessage()); e.printStackTrace(); } } %> ROOM BOOKING LIST <%for (int i = 0; i < records.size(); i++) { JoRoomBookingBean bean = (JoRoomBookingBean) records.elementAt(i);%> <%}%>
DATE NAME PURPOSE STATUS EMID TIME
<%=bean.getDate()%> <%=bean.getName()%> <%=bean.getPurpose()%> <%=bean.getStatus()%> <%=bean.getEmid()%> <%=bean.getTime()%>
Total Records: <%=records.size()%>