Exposed has a connection pool?
How does Database.connect release?
How to use with HikariCP(or similar to this frame)?
I use this code to use HikariCP:
val dataSource : HikariDataSource
constructor()
{
val url = "jdbc:postgresql://" + props("db.host") + ":" + props("db.port") + "/" + props("db.name")
Class.forName("org.postgresql.Driver")
val cfg = HikariConfig()
cfg.jdbcUrl = url
cfg.username = props("db.username")
cfg.password = props("db.password")
dataSource = HikariDataSource(cfg)
Database.connect(dataSource)
logger.info("DB: Connected to $url")
}
@msrd0 your code just init a HikariCP instance, but not related to destructor.
i.g. in web app. pre request a thread call ?
transaction {
logger.addLogger(StdOutSqlLogger)
...
}
all request use just one connection?
I remember I've read once that Exposed closes all connections after the transactions, which means that they are returned to the HikariCP pool. #122 and #123 might be interesting.
I am executing this on the start of every program and use the same instance until the program finishes. I do not see any reason for a destructor, but maybe I got you wrong?
Most helpful comment
I use this code to use HikariCP: