How to create an administrator profile from this code, and when to have a check made if it is a regular user or an administrator?
DaoUsuario.java
package br.edu.facema.model.dao;
import br.edu.facema.model.bean.Usuario;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class DaoUsuario {
public Connection getConnection() {
Connection connection = null;
try {
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "123");
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return connection;
}
public Usuario getUsuario(String login, String senha) {
Connection c = this.getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = c.prepareStatement("select id, nome from usuario where login = ? and senha = ?");
ps.setString(1, login);
ps.setString(2, senha);
rs = ps.executeQuery();
if (rs.next()) {
Usuario user = new Usuario();
user.setId(rs.getInt("id"));
user.setLogin(login);
user.setSenha(senha);
user.setNome(rs.getString("nome"));
return user;
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {;
}
rs = null;
}
if (ps != null) {
try {
ps.close();
} catch (SQLException e) {;
}
ps = null;
}
if (c != null) {
try {
c.close();
} catch (SQLException e) {;
}
c = null;
}
}
return null;
}
}
package br.edu.facema.model.bean;
import java.io.Serializable;
public class Usuario implements Serializable {
private int id;
private String nome;
private String login;
private String senha;
private int tipoUsuario;
public int getTipoUsuario() {
return tipoUsuario;
}
public void setTipoUsuario(int tipoUsuario) {
this.tipoUsuario = tipoUsuario;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
}