I'm using sonarqube to analyse code to check some of it problems. One of the recommendations that the tool has given me is, as the title says, "Use try-with-resources or close this "Statement" in a "finally" clause". I don't know what it is referring to, even after checking some notes. The piece of code is this:
try {
sentencia = conexion.createStatement();
sentencia.executeUpdate(consulta);
dispose();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(this, "No se puede insertar la cita", "Error", JOptionPane.ERROR_MESSAGE);
LOGGER.log(Level.SEVERE,"Excepcion provocada",e1);
}
How can I fix this so it could be express as Sonarqube recommends me?