oatpp / example-postgresql

A complete example of a "CRUD" service (UserService) built with Oat++ and using oatpp ORM with PostgreSQL.
https://oatpp.io/
Apache License 2.0
38 stars 19 forks source link

[oatpp::postgresql::Executor::getConnection()]: Error. Can't connect. #3

Open techstore56 opened 2 years ago

techstore56 commented 2 years ago

reproduce:

$ docker build -t example-postgresql . $ docker run -p 8000:8000 -e CONFIG_PROFILE='dev' -t example-postgresql

D |2021-10-20 04:43:45 1634705025742559| Server:Loading configuration profile 'dev' terminate called after throwing an instance of 'std::runtime_error' what(): [oatpp::postgresql::Executor::getConnection()]: Error. Can't connect.

image

lganzzzo commented 2 years ago

Hello @techstore56 ,

Most probably you don't have the database running. Make sure that you have PostgreSQL database running at the correct address.

Also, it will be much easier to just run docker-compose up to run both database and the service.

lizemin5235 commented 2 years ago

<migration.migrate(); // <-- run migrations. This guy will throw on error.> how to deal this error

lganzzzo commented 2 years ago

<migration.migrate(); // <-- run migrations. This guy will throw on error.> how to deal this error

@lizemin5235 , use try - catch