(multiple) ResultSet problem
I'm quite new to Java, but I couldn't find the answer to my question anywhere.
1. It's an applet
2. I'm using a MS Access 2000 ODBC/JDBC database
3. Everything seems to work. I can connect, I can see the database entry if using the first ResultSet ("SELECT * FROM PARKEERGARAGE WHERE DATUM ='" + datum + "';"). But my 2nd resultset doesn't work. ( else { if (x == 5 || x == 6 || x == 7 || x == 1 || x == 2) { ......... )
4. This is only a small part of a huge applet.
This is what I want:
1. Check if the string is in the database (if yes, show it... that works)
2. If it isn't, calculate (using GregorianCalendar) if it it is a Week or Weekend. (this doesn't work)
3. Whatever it is, retrieve the row with Date = Week or Weekend.
public void zoekOpeningstijden() {
GregorianCalendar calendar;
calendar = new GregorianCalendar(2004,12,30);
}
int i = 0;
String datum = beh_textfield_openingstijden_datum.getText();
int x = calendar.get(calendar.DAY_OF_WEEK);
connect();
try {
ResultSet rs = dbDAS.executeQuery("SELECT * FROM PARKEERGARAGE WHERE DATUM ='" + datum + "';");
while (rs.next()) {
i++;
}
if (i == 1) {
rs.previous();
panel_beh_openingstijden_textarea.setText(rs.getString("DATUM"));
rs.close();
}
else {
if (x == 5 || x == 6 || x == 7 || x == 1 || x == 2) {
rs = dbDAS.executeQuery("SELECT * FROM PARKEERGARAGE WHERE DATUM = 'Week';");
System.out.println(x);
System.out.println(rs.getString("DATUM"));
panel_beh_openingstijden_textarea.setText(rs.getString("DATUM"));
rs.close();
} else if (x == 3 || x == 4) {
rs = dbDAS.executeQuery("SELECT * FROM PARKEERGARAGE WHERE DATUM = 'Weekend';");
panel_beh_openingstijden_textarea.setText(rs.getString("DATUM"));
rs.close();
}
}
} catch (IOException ex) {} catch (SQLException ex) {}
close();
}

