https://kotlinlang.org logo
#announcements
Title
# announcements
n

nkiesel

02/03/2017, 2:07 AM
yes, does the trick. Only missing feature is the "multiple resources in a single try expression" aka
try (Connection c = getConnection(); ResultSet rs = getRS(c, query) { while (rs.next()) { ... } }
e

elizarov

02/03/2017, 8:09 AM
nkiesel: If I were writing a lot of this kind of code then I'd write a couple of helper inline functions for myself, so that my actual DB-access code is clean and beautiful like:
Copy code
withConnection {
    forEachRow(query) { 
         // do something with it
    }
    forEachRow(anotherQuery) { 
         // do something with it
    }
}
In Kotlin you don't have to suffer with repeating bolierplate code.
4 Views