Closed Rakaniyu closed 1 year ago
HAPI will auto-create the tables when it starts up the first time, assuming it is configured correctly and has the proper permissions. I'd expect you'd see errors in the logs if it failed to connect or create the tables.
You might need to uncomment this line in the application.yaml to have it do so: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/application.yaml#L36
I just uncomment it but it still doesn't create the tables, if I connect through PgAdmin 4 to the database, it doesn't seem like it's connected in database activity (I don't know if it should appear but I'm guessing that)
If the server comes up and "works" - and you don't see errors in the log file. I would suspect that it is then spinning up the in-memory H2 database to connect to, rather than your external Postgres.
Did you specify the DB connection properties here: ?
https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/application.yaml#L16
Yes, I modified like this
spring: main: allow-circular-references: true
flyway: enabled: false check-location: false baselineOnMigrate: true datasource: url: 'jdbc:postgresql://localhost:5432/hapi'
username: db_user
password: db_pwd
driverClassName: org.postgresql.Driver
max-active: 15
# database connection pool size
hikari:
maximum-pool-size: 10
jpa: properties: hibernate.format_sql: false hibernate.show_sql: false
#Hibernate dialect is automatically detected except Postgres and H2.
#If using H2, then supply the value of ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect
#If using postgres, then supply the value of ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect
hibernate.dialect: ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect
hibernate.hbm2ddl.auto: update
hibernate.search.enabled: false
Sorry it's copied horrible, i attach the file in txt format
Looks correct. Can you reach the server when it comes up? Like can you search /Patient ? Anything in the logs?
My guess at this point would be that it is not picking up your application.yaml file. How are you packaging it? How are you running the server?
The server works perfectly and I can POST the fhir resources.
For running the server, I clon this repository and then run docker-compose up
The Docker compose includes a Postgres image. So I suspect that HAPI is connecting to that postgres instance within the container rather than your external instance running on your own localhost. (Localhost to the docker container would be the docker container itself, not your computer, I think) .
Yes I know and i'm connecting to that Postgres database. That's why I use localhost in application.yaml but HAPI is connecting to I don't know where
I'm mostly out of ideas. You could:
That's about all I can think to try.
Yes i've already tried that, I'm convinced that is HAPI connecting to another internal database or something like that.
Anyways, thanks you so much for your time
I've just resolved it!
The problem was in application.yaml in
datasource:
url: 'jdbc:postgresql://localhost:5432/fhir'
localhost must be changed with postgres container name for example
datasource:
url: 'jdbc:postgresql://hapi-fhir-postgres:5432/fhir'
Hi there, i've already make all changes needed to connect HAPI Server to a postgres database but when I connect to database, I don't see the tables from HAPI.