I was trying to set the password entered in a JPasswordField and this error appeared:
"Incompatible types: char[] cannot be converted to String"
dts.setSalary(Double.parseDouble(txtSalary.getText()));
selected=chgAccess.getSelectedIndex();
dts.setAccess_number((String)chgAccess.getItemAt(selected));
dts.setLogin(txtLogin.getText());
//HERE
dts.setPassword((String)txtPassword.getPassword());
How can I fix it?
extra question: then it's supposed to go as a VARCHAR type in my database, will it work? I mean, I have created the spaces in the database for text not for passwords; I didn't find a datatype password in MySQL.
getPassword()
returns achar[]
- it cannot be simply cast to ajava.lang.String
. You could, however, construct a new String for this char array:Or, better yet: