On Thursday, 28 July 2016 at 14:24:16 UTC, Suliman wrote:
void dbInsert(string login, string uploading_date, string
geometry_type, string data)
{
Statement stmt = conn.createStatement();
//stmt.executeUpdate("...");
// some processing of request
scope(exit) stmt.close(); // closing
}
void getIMGsMetadataFromDB(Json request)
{
Statement stmt = conn.createStatement();
//stmt.executeWuery("...");
// some processing of request
scope(exit) stmt.close(); // closing
}
Is this code is more correct?
You'd have to go with
Statement stmt = conn.createStatement();
scope(exit) stmt.close();
//stmt.executeUpdate...
//some processing
stmt.close will be called only when leaving the scope, although
it appears right after stmt initialization. Check this out:
https://dlang.org/spec/statement.html#scope-guard-statement