How to know if a ResultSet contains Null in column?

1

I try to formulate a condition which is if my column x contains Null send me a message, if it is not so I fill a excel . I have a lake of this style, Thanks !!.

if (res.next()) {
    while (res.next()) {
        Row filaDatos = sheet.createRow(numfilaDatos);
        for (int a = 0; a < numCol; a++) {
            Cell celdaDatos = filaDatos.createCell(a);
            celdaDatos.setCellValue(res.getString(a + 1));
        }
        numfilaDatos++;
    }
    fileOut = new FileOutputStream("Solicitud_R3.xlsx");
    book.write(fileOut);
    fileOut.close();
    JOptionPane.showMessageDialog(null, "Archivo de Solicitud Generado");

} else {
    JOptionPane.showMessageDialog(null, "No Existen Faltantes de R3");
}
    
asked by Summer 26.07.2018 в 19:30
source

1 answer

0

When you get the ResultSet you can use the wasNull () method to perform this validation:

   if (rs.wasNull()) {
        //Contiene valor null
    }
  

wasNull () Reports if the last column reading had a   SQL value NULL. Keep in mind that you must first call one of   the getter methods in a column to try to read its value and then   call the wasNull method to see if the value read was SQL NULL

    
answered by 26.07.2018 / 19:43
source