Saying I have an autocloseable resource (returned by a Sql.query call), then is it mandatory to put its return into a variable and try-with-resource it to avoid resource leaking?
try (final Sql sql = ...) {
// sql.query instanciates a java.sql.ResultSet and returns it
sql.query("SET @x := 1");
}
In such case, is it mandatory to change this code to:
try (final Sql sql = ...) {
// sql.query instanciates a java.sql.ResultSet and returns it
try (final ResultSet useless = sql.query("SET @x := 1")) {}
}
To avoid having a non-closed java.sql.ResultSet
? I find no clear documentation about that case... I guess it should be, but I find no clear documentation about it (and since it feels strangely heavy, I'm not sure it's actually required)