I'm not sure what error message you are getting (perhaps you could post some details up).
However, the following line needs to be altered:
String sql = "update user set role = " + jComboBox1.getSelectedItem()+ " where userID =" + jComboBox2.getSelectedItem() + ";";
Notice the space before the "where" and the semi-colon at the end of the statement.
A better version would look like:
public int updateRoleForUser (String role, Integer userId) throws Exception {
int i = 0;
String sql =
" update user "
+ " set role = ?"
+ " where userId = ?;";
try {
conDBase = getConnection();
ps = conDBase.prepareStatement(sql);
ps.setString(1, role);
ps.setInt(2, userId);
i = ps.executeUpdate();
} catch (Exception e) {
// do something with Exception here. Maybe just throw it up again
} finally {
closeConnection();
return i;
}
};
Then call the method using the values from your Combo Boxes.
You should really put the whole lot into a method within a DAO class of some description and then pass in the role and userId values as parameters;