I am developing a small application of a private clinic and to enter the application, I first select the patient's identifier through JComboBox
.
Then, I have a method to fill a arrayList
with the patients' data to later fill in a form with said data.
The problem I have when filling this array
, before filling it I capture all the values of resultset
and in the exception I miss this error:
can not call getNString () when field's charset isn't UTF-8
I sense that this exception is jumping because some field of BD
has a charset
different, but I can not find out why.
I am enclosing my current source where the error is occurring:
public void llenarArrayList() throws UnsupportedEncodingException{
resultSet = mysql.ejecutaConsulta("SELECT * FROM paciente WHERE NUS =" + jcNuss.getSelectedItem());
int nuss = 0;
String cadena = "";
String primerApellido = new String(cadena.getBytes(), "UTF-8");
String segundoApellido = new String(cadena.getBytes(), "UTF-8");
String nombre = new String(cadena.getBytes(), "UTF-8");
int telf = 0;
Date fechaNacimiento = null;
Date fechaAlta = null;
int medicamento = 0;
try {
while(resultSet.next()){
nuss = resultSet.getInt(1);
nombre = resultSet.getString(2);
primerApellido = resultSet.getString(3);
segundoApellido = resultSet.getNString(4);
telf = resultSet.getInt(5);
fechaNacimiento = resultSet.getDate(5);
fechaAlta = resultSet.getDate(6);
medicamento = resultSet.getInt(7);
}
System.out.println("nus: " + nuss + " Nombre: " + nombre + " apellido: " + primerApellido + " apellido2: " +
segundoApellido + " telf: " + telf + " fechaNacimiento: " + fechaNacimiento + " fechaAlta: " + fechaAlta+
" medicam " + medicamento);
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
thanks in advance.