1
My method is not returning the professor logged in.
public Professor autenticarUsuario(String usuario, String senha) {
String SQL = "select * from PROFESSOR where USUARIO = ? and SENHA = ? ";
String[] selectionArgs = new String[] { usuario, senha };
Cursor cursor = dataBase.rawQuery(SQL, selectionArgs);
int idRow;
Professor professor=null;
if (cursor.getCount() > 0){
if (cursor.moveToFirst()){
professor = new Professor();
idRow = cursor.getInt(cursor.getColumnIndexOrThrow("rowid"));
professor.setCodProfessor(cursor.getString(cursor.getColumnIndexOrThrow("CODPROF")));
professor.setNomeProfessor(cursor.getString(cursor.getColumnIndexOrThrow("NOME")));
professor.setUsuario(cursor.getString(cursor.getColumnIndexOrThrow("USUARIO")));
professor.setSenha(cursor.getString(cursor.getColumnIndexOrThrow("SENHA")));
}
}
cursor.close();
Return professor;}
Table:
CREATE TABLE PROFESSOR"+
"(CODPROF VARCHAR(10) PRIMARY KEY,"+
"NOME VARCHAR(40),"+
"USUARIO VARCHAR (60),"+
"SENHA VARCHAR (60));"