All pastes #471568 Raw Edit

avalys

public java v1 · immutable
·published 2007-05-04 23:29 UTC
rendered paste body
public Reservation[] getReserves(String query) throws SQLException {		Statement stmt = dbCon.createStatement();		System.out.println(query);		ResultSet rs = stmt.executeQuery(query);		List resp = new Vector();		String currentUser = "none_valys";		String currentE = "Alex Valys";		String currentDate = "yesterday";		String periods = "";		Reservation r = null;		// This is so horribly, horribly executed.  I was tired.		while(rs.next()) {			String theUser = rs.getString("username");			String theDate = formatDate(rs.getString("date"));			String theE = rs.getString("name");			if (!currentDate.equals(theDate) || !currentUser.equals(theUser) || !currentE.equals(theE)) {				if (r != null) {					r.periods = periods;					resp.add(r);				}				r = new Reservation();				currentUser = theUser;				currentDate = theDate;				currentE = theE;				r.user = theUser;				r.date = theDate;				r.equipment = theE;				r.room = rs.getString("room");				r.eID = rs.getString("eid");				periods = "";			}			periods = periods+rs.getString("short")+" ";		}		if (r != null) {			r.periods = periods;			resp.add(r);		}		return (Reservation[]) resp.toArray(new Reservation[resp.size()]);	}