I'm using jetbrains' exposed library to create and populate a database.
The database does not exist, and I am creating it. However I could not find a simple way to connect to the SQL engine, create a database and connect to that database without multiple connections. That sounds a little clunky. Is there a better way to do it maybe?
Here is a small example :
var db = Database.connect("jdbc:mysql://localhost:3308", driver = "com.mysql.jdbc.Driver", user = "root", password = "aRootPassword")
transaction(db) { SchemaUtils.createDatabase("imdb") }
// avoid reconnect?
db = Database.connect("jdbc:mysql://localhost:3308/imdb", driver = "com.mysql.jdbc.Driver", user = "root", password = "aRootPassword")
transaction(db) { SchemaUtils.create (TitleRatings) }