che è meglio per blocco finally:Chiudere la connessione e la dichiarazione, infine
finally {
try {
con.close();
stat.close();
} catch (SQLException sqlee) {
sqlee.printStackTrace();
}
}
Oppure:
finally {
try {
if (con != null) {
con.close();
}
if (stat != null) {
stat.close();
}
} catch (SQLException sqlee) {
sqlee.printStackTrace();
}
}
Ebbene, dal momento che il primo avrebbe gettato un NPE ... –
Si dovrebbe chiudere la dichiarazione prima del collegamento. –
@MarkRotteveel bella nota, puoi dirmi perché? – Sajad