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;
}
Aggregations