Non riesco a fare una query che mi confronta il numero di matricola con la colonna code di un tabella fatta con access. La ricerca dovrebbe trovare la matricola corrispondente della colonna code e risultare a video, nome cognome e numero di matricola, cioè la riga in cui a trovato la matricola corrispondente. Per favore aiutatemi.......Grazie!!!!
public DataBaseManager(String code) {
matr= code;
// System.out.println(matr);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(ClassNotFoundException e) {
e.printStackTrace();
}
}
public void connect(String name, String user, String password) throws SQLException {
connection = DriverManager.getConnection(name, user, password);
}
public void disconnect() {
try {
connection.close();
} catch(Throwable t) {
// Intentionally blank
}
}
public void print(String students) throws SQLException {
Statement s = connection.createStatement();
try {
System.out.println(matr);
ResultSet r = s.executeQuery("SELECT * FROM " + students + " where CODE = ' " + matr + " ' " );
ResultSetMetaData m = r.getMetaData();
int columnCount = m.getColumnCount();
for (int i = 1; i <= columnCount; i++) {
System.out.print(formatString(m.getColumnName(i)) + " ");
}
System.out.println();
try {
while(r.next()) {
for (int i = 1; i <= columnCount; i++) {
String columnName = m.getColumnName(i);
Object value = r.getObject(columnName);
System.out.print(formatString(value.toString()) + " ");
}
System.out.println();
}
} catch(SQLException x) {
// Intentionally blank
}
r.close();
} catch(SQLException e) {
s.close();
throw e;
}
s.close();
}