DanielaSfregola / get-programming-with-scala

Code for the book "Get Programming with Scala" (Manning)
https://www.manning.com/books/get-programming-with-scala?a_aid=daniela&a_bid=7cd2421c
MIT License
79 stars 32 forks source link

Unit 7 Lesson 46 #97

Closed mentat31 closed 2 years ago

mentat31 commented 2 years ago

Trying to do the Database Queries with Quill lesson and seem to be running into a problem.

When calling queries.testConnection() I get the error;

com.github.jasync.sql.db.exceptions.UnsupportedAuthenticationMethodException: Unknown authentication method -> '10'

I've tried looking into the container with little luck by finding some helpful messages about modifying the postgresql.config before the container starts... but this is docker, so before making my own image I just wanted to see if anyone else has had this problem. On macOS if that helps.

DanielaSfregola commented 2 years ago

Hi @mentat31, have you tried running the solution (code published in this repo)? That will tell us if your problem is code or setup related.

Cheers, Daniela

lamazoni commented 2 years ago

I m experiencing this pb too. If I put a breakpoint I can see that I can connect to the db with a tool like omnidb with a string like postgresql://localhost:32805/test?user=test&password=test but the following modification seems to have no effect : PostgreSQL.scala (unit7 lesson 47)

    val components = List(
//      container.getJdbcUrl,
      "postgresql://" + container.getContainerIpAddress + ":" + container.getMappedPort(PostgreSQLContainer.POSTGRESQL_PORT) + "/" + container.getDatabaseName,
// with a manually launched container "postgresql://127.0.0.1:5432/test?",
      s"user=${container.getUsername}",
      s"password=${container.getPassword}"
    ) 

I was thinking that there was a auth parameter somewhere (I had some sucess by launching manually a container with -e POSTGRES_INITDB_ARGS=–auth-host=md5) but I can't find any ...

PS: launching the container manually with the change above (the part of the code with the container test as to be removed as well)

WORKING_DIR=`put your root scala working directory here`
docker run -p 127.0.0.1:5432:5432 -e POSTGRES_INITDB_ARGS=--auth-host=md5 -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -e POSTGRES_DB=test -v $WORKDIR/src/main/resources/:/docker-entrypoint-initdb.d/ postgres -c max_connections=200
mentat31 commented 2 years ago

Hi @mentat31, have you tried running the solution (code published in this repo)? That will tell us if your problem is code or setup related.

Cheers, Daniela

Just seeing this today, however after a couple of days of debugging I found a solution. I noticed in the log that AuthenticationStartupParser.kt didn't have all the authentication methods that I was seeing on their github.

I added "com.github.jasync-sql" % "jasync-postgresql" % "2.0.7" to my build.sbt and it now seems to be working! Thank you for your response!