JDBC connection in ZIO

When using plain JDBC in ZIO (without ZIO-JDBC or ZIO-SQL), what should I watch out for regarding thread safety and fiber scheduling, especially when working with transactions?

I don’t want to use ZIO-JDBC or ZIO-SQL as it looks like both projects are not actively maintained plus I do want to understand how those things work with ZIO before using an external library.

At the moment I use HikariCP and single SQL statements with autoCommit enabled in ZIO.scoped.

I don’t know the whole ZIO API but you’ll basically have to make sure that you wrap every blocking call in something like ZIO.attemptBlocking(…). E.g. opening a connection, executing a query, etc.

1 Like