package swbd;
import java.sql.*;
public class Utente {
private String nome;
private String password;
private boolean autorizzato;
public Utente(String n, String p) {
nome = n;
password = p;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:swbd");
Statement stm = conn.createStatement();
String query = "select * from utente where nome='" + nome + "'";
ResultSet rst = stm.executeQuery(query);
autorizzato = false;
if (rst.next())
if (password.equals(rst.getString("password")))
autorizzato = true;
} catch (Exception e) {
System.out.println("Problemi");
System.exit(0);
}
}public boolean isAutorizzato() {
return autorizzato;
}public String getNome() {
return nome;
}
}