-1

I am using Ratpack and Postgres to create a simple application, currently I am just adding data into my Postgres database.

The data gets mapped to my groovy object and then inserted into the database fine however in my logs I come across this error.

ratpack-blocking-34-1] WARN com.zaxxer.hikari.pool.HikariPool - Exception during keep alive check, that means the connection (org.postgresql.jdbc4.Jdbc4Connection@1b89ab21) must be dead. org.postgresql.util.PSQLException: ERROR: relation "hospital" does not exist

It's working as expected but I'm not sure what I am doing wrong to get this error.

Here is my code for adding the data into my database.

@Override
Operation save(Hospital hospital) {
    Blocking.get {
        sql.execute "INSERT INTO hospitals (id,name) VALUES (${hospital.id}, ${hospital.name})"
    }.operation()
}

and then here is my handler

void handle(Context ctx, HospitalService hospitalService) {
    ctx.byMethod { method ->
        method.post {
            ctx.parse(Form). then { form ->
                def name = form.name
                if (name) {
                    def id = UUID.randomUUID()
                    def hospital = new Hospital(id: id, name: name)
                    hospitalService.save(hospital).onError { error ->
                        ctx.render json([success: false, error: error.message])
                    } then {
                        ctx.render handlebarsTemplate("added-new.html")
                    }
                } else {
                    ctx.response.status(400)
                    ctx.render(json([success: false, error: "name is required"]))
                }
            }
        }

Can anyone see why I am getting this message? Even though it seems to be working as expected.

pocockn
  • 1,965
  • 5
  • 21
  • 36
  • Possible duplicate of [HikariCP with PostgreSQL: setQueryTimeout(int) is not yet implemented](http://stackoverflow.com/questions/26550316/hikaricp-with-postgresql-setquerytimeoutint-is-not-yet-implemented) – pocockn Jun 15 '16 at 13:45

1 Answers1

0

Followed the instructions here

HikariCP with PostgreSQL: setQueryTimeout(int) is not yet implemented

It was a problem to do with my connectionTestQuery not referencing the correct table in my database in the constructor.

Community
  • 1
  • 1
pocockn
  • 1,965
  • 5
  • 21
  • 36