Search in sources :

Example 16 with NodeUser

use of mom.trd.opentheso.bdd.helper.nodes.NodeUser in project opentheso by miledrousset.

the class UserHelper method getIdUser.

/**
 * cette fonction permet de retourner l'identifiant d'un utlisateur suivant
 * son Nom
 *
 * @param conn
 * @param userName
 * @return
 */
public int getIdUser(Connection conn, String userName) {
    int idUser = -1;
    Statement stmt;
    ResultSet resultSet;
    try {
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT id_user FROM users" + " WHERE" + " username = '" + userName.trim() + "'";
                resultSet = stmt.executeQuery(query);
                if (resultSet.next()) {
                    NodeUser nu = new NodeUser();
                    idUser = resultSet.getInt("id_user");
                }
            } finally {
                stmt.close();
            }
        } finally {
        }
    } catch (SQLException ex) {
        Logger.getLogger(UserHelper.class.getName()).log(Level.SEVERE, null, ex);
    }
    return idUser;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) ResultSet(java.sql.ResultSet)

Aggregations

NodeUser (mom.trd.opentheso.bdd.helper.nodes.NodeUser)16 SQLException (java.sql.SQLException)9 Connection (java.sql.Connection)7 PreparedStatement (java.sql.PreparedStatement)7 ResultSet (java.sql.ResultSet)7 Statement (java.sql.Statement)7 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)6 FacesMessage (javax.faces.application.FacesMessage)5 ArrayList (java.util.ArrayList)3 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)3 NodeProposition (mom.trd.opentheso.bdd.helper.nodes.candidat.NodeProposition)3 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 FacesContext (javax.faces.context.FacesContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 CurrentUser (mom.trd.opentheso.SelectedBeans.CurrentUser)1 SelectedCandidat (mom.trd.opentheso.SelectedBeans.SelectedCandidat)1 BaseDeDoneesHelper (mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper)1 Connexion (mom.trd.opentheso.bdd.helper.Connexion)1