IllegalStateException: Can not connect to database. Please check connectivity and settings - postgresql

CentOS 7
Docker 20.10.5
In my machine run PostgreSQL 9.5 and success open my db:
localhost:5432/sonar
And success open DB by PGAdmin
Nice.
Now in Docker I installed SonarQube 4.5. And want to connect to my db.
I try this:
sudo docker run -e SONARQUBE_JDBC_USERNAME=sonar -e SONARQUBE_JDBC_PASSWORD=sonar -e SONARQUBE_JDBC_URL=jdbc:postgresql://localhost:5432/sonar sonarqube:4.5.7
But I get error:
2021.04.20 11:47:55 INFO web[o.s.s.p.ServerImpl] SonarQube Server / 4.5.7 / e2afb0bff1b8be759789d2c1bc9348de6f519f83
2021.04.20 11:47:55 INFO web[o.s.c.p.Database] Create JDBC datasource for jdbc:postgresql://localhost:5432/sonar
2021.04.20 11:47:55 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener
java.lang.IllegalStateException: Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').
at org.sonar.core.persistence.DefaultDatabase.checkConnection(DefaultDatabase.java:115) ~[sonar-core-4.5.7.jar:na]
at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:73) ~[sonar-core-4.5.7.jar:na]

Related

unable to make connection between MSSQL and python image using Docker compose

I am using Docker compose to build images of python and MSSQL and making connection between DB and python app and added DB container as a server in python.connection file but getting errors like
pyodbc.OperationalError: ('08001', '[08001] [FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
Adaptive Server is unavailable or does not exist
'DRIVER={FreeTDS};''SERVER=MSSQL_DB;''PORT=1433;' 'DATABASE=MYDATABASE;''TDS_Version=7.4', autocommit=True) my_python_app | pyodbc.OperationalError: ('08001', '[08001] [FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')

Hyperledger iroha - schema error while connecting to postgres database

I am trying to deploy Hyperledger Iroha on MacOS (BigSUr) locally, and while running the following command
./build/bin/irohad --config example/config.postgres.sample --genesis_block example/genesis.block --keypair_name example/node0
I get the error
Storage initialization failed: Cannot execute query. Fatal error. ERROR: relation "schema_version" does not exist LINE 1: ... test, iroha_major, iroha_minor, iroha_patch from schema_ver... ^ while executing "select 1 test, iroha_major, iroha_minor, iroha_patch from schema_version;".
I have installed Postgresql DB locally and created the iroha_data database.
Is there a schema that i must load additionally or does it get auto created ?
I was able to overcome this issue by adding -drop_state while starting iroha daemon.

Unable to execute Liquibase update commands via Docker run

I am using docker here to build Liquibase and trying to execute Liquibase commands on fly.
Here is the Dockerfile:-
FROM liquibase/liquibase
RUN lpm add mysql --global
I am using below command on fly
docker run --rm -v ${bamboo.build.working.directory}/:/liquibase/changelog liquibase/liquibase --url="jdbc:postgresql://app-liquibase-test.us-region.rds.amazonaws.com:5432/database?currentSchema=schema" --changeLogFile=sql/changelog/db.changelog-master.xml --username=username --password=password update
I am getting below error:-
error 04-May-2022 22:08:38 Starting Liquibase at 05:08:38 (version 4.9.1 #1978 built at 2022-03-28 19:39+0000)
error 04-May-2022 22:08:38 Liquibase Version: 4.9.1
error 04-May-2022 22:08:38 Liquibase Community 4.9.1 by Liquibase
error 04-May-2022 22:08:48
error 04-May-2022 22:08:48 Unexpected error running Liquibase: Connection could not be created to jdbc:postgresql://app-liquibase-test.us-region.rds.amazonaws.com:5432/database?currentSchema=schema with driver org.postgresql.Driver. The connection attempt failed.
Please suggest
From this October 2021 GitHub issue, you need to use single quotes around your JDBC driver URL instead of double-quotes. Try entering it as edited below.
docker run --rm -v ${bamboo.build.working.directory}/:/liquibase/changelog liquibase/liquibase --url='jdbc:postgresql://app-liquibase-test.us-region.rds.amazonaws.com:5432/database?currentSchema=schema' --changeLogFile=sql/changelog/db.changelog-master.xml --username=username --password=password update

Alembic / Flask-migrate migration on Heroku runs but does not create tables

I am attempting to deploy a Flask app to Heroku. I have pushed to Heroku and can access my login page but any call to the db gives an OperationalError:
2014-01-29T12:12:31.801772+00:00 app[web.1]: OperationalError: (OperationalError) no such table: projects_project u'SELECT
Using Flask-migrate I can successfully run local migrations and upgrades:
INFO [alembic.migration] Context impl PostgresqlImpl.
INFO [alembic.migration] Will assume transactional DDL.
INFO [alembic.migration] Running upgrade None -> 4b56d58e1d4c, empty message
When I try to upgrade on Heroku using heroku run python manage.py db upgrade the upgrade appears to happen, but the Context impl. is now SQLite?:
(dev01)Toms-MacBook-Pro:dev01 kt$ heroku run python manage.py db upgrade
Running `python manage.py db upgrade` attached to terminal... up, run.9069
INFO [alembic.migration] Context impl SQLiteImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
INFO [alembic.migration] Running upgrade None -> 4b56d58e1d4c, empty message
Running Heroku pg:info gives:
=== HEROKU_POSTGRESQL_PINK_URL (DATABASE_URL)
Plan: Dev
Status: available
Connections: 0
PG Version: 9.3.2
Created: 2014-01-27 18:55 UTC
Data Size: 6.4 MB
Tables: 0
Rows: 0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
The relevant logs for the Heroku upgrade are:
2014-01-29T12:55:40.112436+00:00 heroku[api]: Starting process with command `python manage.py db upgrade` by kt#gmail.com
2014-01-29T12:55:44.638957+00:00 heroku[run.9069]: Awaiting client
2014-01-29T12:55:44.667692+00:00 heroku[run.9069]: Starting process with command `python manage.py db upgrade`
2014-01-29T12:55:44.836337+00:00 heroku[run.9069]: State changed from starting to up
2014-01-29T12:55:46.643857+00:00 heroku[run.9069]: Process exited with status 0
2014-01-29T12:55:46.656134+00:00 heroku[run.9069]: State changed from up to complete
Also, heroku config gives me:
(dev01)Toms-MacBook-Pro:dev01 kt$ heroku config
=== myapp Config Vars
DATABASE_URL: postgres://xxx.compute-1.amazonaws.com:5432/da0jtkatk6057v
HEROKU_POSTGRESQL_PINK_URL: postgres://xxx.compute-1.amazonaws.com:5432/da0jtkatk6057v
where [xxx == xxx]
How is the Context impl. set? Apart from this obvious difference between working local and heroku, I can't work out what's happening or how I should debug. Thanks.
The URL for the database is taken from the SQLALCHEMY_DATABASE_URI configuration in your Flask app instance. This happens in the env.py configuration for Alembic that was created in the migrations folder.
Are you storing the value of os.environ['DATABASE_URL'] in the configuration before you hand over control to Flask-Migrate and Alembic? It seems you have a default SQLite based database that never gets overwritten with the real one provided by Heroku.

PropelBundle database:create for postgres

I've installed propel bundle for symfony2.
my database configuration is:
propel:
dbal:
driver: pgsql
user: postgres
password: postgres
dsn: pgsql:host=localhost;port=5432;dbname=test_database
options: {}
attributes: {}
When i wan to create this database from console (console propel: database:create) i have got strange error : Unable to open PDO connection [wrapped: SQLSTATE[08006] [7] FATAL: database "pgsql" does not exist.
i created pgsql database on my localhost and everything was good. Database "test_database" was succesfull created. Can somebody explain me why i got this previous error? On mysql i've created database without any problems.
This issue was a bug in the PropelBundle, it has been fixed by the following commit (even if the commit message is about MySQL, it fixes other RDBMS): https://github.com/propelorm/PropelBundle/commit/b4475d27fb1eb846d10cc2d2e2bd164f037508e3
I 've installed new PropelBundle via Composer and everything is ok now. I think maybe it was a problem with 1.0 bundle , now I have 1.1