I just started with scala and want to build a connection to my DB.
(My knowledge stems from the scala/doobie Tutorial's on https://www.scala-exercises.org/)
Now here is the Code:
import doobie._
import doobie.implicits._
import cats.effect._
import cats.implicits._
import doobie.hikari._
...
val transactor: Resource[IO, HikariTransactor[IO]] =
for {
ce <- ExecutionContexts.fixedThreadPool[IO](32) // our connect EC
be <- Blocker[IO] // our blocking EC
xa <- HikariTransactor.newHikariTransactor[IO](
"org.h2.Driver", // driver classname
"jdbc:mysql://localhost:3306/libraries", // connect URL
"root", // username
"", // password
ce, // await connection here
be // execute JDBC operations here
)
} yield xa
When I try to Build my Code i get the following error message:
Error:(25, 53) Cannot find an implicit value for ContextShift[cats.effect.IO]:
import ContextShift[cats.effect.IO] from your effects library
if using IO, use cats.effect.IOApp or build one with cats.effect.IO.contextShift xa <- HikariTransactor.newHikariTransactor[IO](
Now I've got two questions:
- What exactly is the problem?
- How do I fix it?