It’s been a while, but I’m happy to be using some Kotlin again. First thing I’m trying to do is query some relational DBs. Any recommendations on ways to do this, beyond strait JDBC? In Python, I can do something like:
for id, name, dt, foo in query("select id, name, dt, foo from table t join … "):
But in JDBC that becomes much for verbose with many lines like:
val id = rs.getInt(1)
val name = rs.getString(2)
val foo = rs.getTimestamp(3)
… or similar for setting input query parameters. I like the types, but I’d like to cut down the boilerplate. I’m thinking I could declare a data class for the rows and maybe write a method like query that uses reflection to call all the ResultSet.getFoo(n) methods for me. Maybe something like that exists already?