fun <T> withConnection(url: String, user: String, password: String, body: (db: Database) -> T): T
Execute a body of code with a new JDBC connection that is held within a Database
instance.
If the client code makes that Database
instance available to other threads, it is
the client's responsibility do do any needed synchronization. When the code body exits,
the connection is closed, and the Database
instance is no longer usable.
Usage example:
Database.withConnection("jdbc:h2:mem:test", "root", "") { db ->
various operations on db
}