I am trying to connect Corda 4.1 (open source) to Azure PostgreSQL.
With the following in the node.conf:
dataSourceProperties = {
dataSourceClassName = "org.postgresql.ds.PGSimpleDataSource"
dataSource.url = "jdbc:postgresql://my-dev-corda-db.postgres.database.azure.com:5432/banks"
dataSource.user = "me#my-dev-corda-db"
dataSource.password = Password
}
It throws the error:
[ERROR] 2019-08-08T23:44:45,301Z [main] internal.NodeStartupLogging.invoke - Could not connect to the database. Please check your JDBC connection URL, or the connectivity to the database.: Could not connect to the
database. Please check your JDBC connection URL, or the connectivity to the database. [errorCode=uz1y94, moreInformationAt=https://errors.corda.net/OS/4.1/uz1y94]
net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException: Could not connect to the database. Please check your JDBC connection URL, or the connectivity to the database.
....
....
Suppressed: org.postgresql.util.PSQLException: FATAL: SSL connection is required. Please specify SSL options and retry.
...
So I add ssl=true to the url:
dataSource.url = "jdbc:postgresql://my-dev-corda-db.postgres.database.azure.com:5432/banks?ssl=true"
and it throws the error:
[ERROR] 2019-08-08T23:49:45,409Z [main] internal.NodeStartupLogging.invoke - Could not connect to the database. Please check your JDBC connection URL, or the connectivity to the database.: Could not connect to the
database. Please check your JDBC connection URL, or the connectivity to the database. [errorCode=17q5mal, moreInformationAt=https://errors.corda.net/OS/4.1/17q5mal]
net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException: Could not connect to the database. Please check your JDBC connection URL, or the connectivity to the database.
...
...
Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not open SSL root certificate file /home/corda/.postgresql/root.crt.
...
Caused by: org.postgresql.util.PSQLException: Could not open SSL root certificate file /home/corda/.postgresql/root.crt.
...
I then tried setting the sslmode=require:
dataSource.url = "jdbc:postgresql://my-dev-corda-db.postgres.database.azure.com:5432/banks?ssl=true&sslmode=require"
which then errors with:
[ERROR] 2019-08-08T23:53:38,323Z [main] internal.NodeStartupLogging.invoke - Could not connect to the database. Please check your JDBC connection URL, or the connectivity to the database.: Could not connect to the
database. Please check your JDBC connection URL, or the connectivity to the database. [errorCode=uz1y94, moreInformationAt=https://errors.corda.net/OS/4.1/uz1y94]
net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException: Could not connect to the database. Please check your JDBC connection URL, or the connectivity to the database.
...
...
Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: FATAL: no pg_hba.conf entry for host "57.211.24.3", user "me", database "banks", SSL on
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:512) ~[HikariCP-2.5.1.jar:?]
...
Caused by: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "57.211.24.3", user "me", database "banks", SSL on
...
What are the full correct steps to use Azure PostgreSQL with Corda?
When you connect from Internet to Azure PostgreSQL you need to enable your IP in the server's firewall, see: https://learn.microsoft.com/en-us/azure/postgresql/concepts-firewall-rules#connecting-from-the-internet.
You can do it simply from Azure portal - go to Connection Security and Add Client IP (if you don't have a static IP, then you need to repeat it each time).
For JDBC connection settings only ?sslmode=require is needed, so in your node configuration use:
dataSource.url = "jdbc:postgresql://my-dev-corda-db.postgres.database.azure.com:5432/banks?sslmode=require"
Related
I'm working on JDK8 and using mongo-java-driver(v3.5.0) to connect MongoDB(v3.6.3).
I've enabled SSL by following this article. I don't have /etc/mongod.conf file, instead I've /etc/mongodb.conf file; so I've updated the SSL settings in that file:
# SSL options
# Enable SSL on normal ports
sslOnNormalPorts = true
# SSL Key file and password
sslPEMKeyFile = /etc/ssl/mongodb.pem
sslPEMKeyPassword = PASSWORD
I'm able to access mongo via mongo shell using:
mongo --ssl --sslCAFile /etc/ssl/rootCA.pem --sslPEMKeyFile /etc/ssl/mongodb.pem --host localhost
I want to connect MongoDB using Java driver. I initially tried the following JDBC connection string:
mongodb://USER:PASSWORD#localhost:27017/?ssl=true&sslAllowInvalidCertificates=true&sslPEMKeyFile=/etc/ssl/mongodb.pem
but as per documentation, there are no such options available. Also, I get error:
The connection string contains an invalid host 'localhost:27017/?ssl=true&sslAllowInvalidCertificates=true&sslPEMKeyFile=/etc/ssl'. The port '27017/?ssl=true&sslAllowInvalidCertificates=true&sslPEMKeyFile=/etc/ssl' is not a valid, it must be an integer between 0 and 65535
And when I try with the following connection string:
url=mongodb://USER:PASSWORD#localhost:27017/?ssl=true
I get following error:
com.mongodb.MongoSocketWriteException: Exception sending message
at com.mongodb.connection.InternalStreamConnection.translateWriteException(InternalStreamConnection.java:445) ~[mongo-java-driver-3.5.0.jar:?]
.
...
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
.
...
Here's the code that I've used:
String url = "mongodb://USER:PASSWORD#localhost/?authSource=admin&ssl=true"
MongoClientURI connectionURI = new MongoClientURI(url)
mongoClient = new MongoClient(connectionURI)
Could someone help me with what JDBC connection string I need to configure to connect successfully. Thank you.
Not sure if I'm missing anything.
I'm trying to create a local connection in order to create a new user in Oracle SQL developer 12c. (AVOIDING CDB connection)
After browsing for an hour, came across 2 methods.
Using connection type as "Local/Bequeath"
Throws following error (Status : Failure -Test failed: ORA-01017: invalid username/password; logon denied)
Using connection type as "Basic", Hostname as "localhost", Port as "1521", and Service name as "XEPDB1"
Throws following error (Status : Failure -Test failed: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor)
Thanks.
I am doing PoC on KSQLDB Elasticsearch connector.
I am following from 2 documents online:
One:
https://ksqldb.io/quickstart.html
All working fine and well and after I fallowed
Second one:
https://github.com/confluentinc/demo-scene/blob/master/build-a-streaming-pipeline/demo_build-a-streaming-pipeline.adoc
I am getting this issue when I run this command:
CREATE SINK CONNECTOR SINK_ES_sample_1 WITH (
'connector.class' = 'io.confluent.connect.elasticsearch.ElasticsearchSinkConnector',
'topics' = 'sample_1',
'connection.url' = 'http://localhost:9200',
'type.name' = '_doc',
'key.ignore' = 'false',
'schema.ignore' = 'true',
'transforms'= 'ExtractTimestamp',
'transforms.ExtractTimestamp.type'= 'org.apache.kafka.connect.transforms.InsertField$Value',
'transforms.ExtractTimestamp.timestamp.field' = 'sample_1'
);
Error:
io.confluent.ksql.util.KsqlServerException:
org.apache.hc.client5.http.HttpHostConnectException: Connect to
http://localhost:8083 [localhost/127.0.0.1] failed: Connection refused
(Connection refused) Caused by:
org.apache.hc.client5.http.HttpHostConnectException: Connect to
http://localhost:8083 [localhost/127.0.0.1] failed: Connection
refused (Connection refused) Caused by: Could not connect to the
server. Please check the server details are correct and that the
server is running.
That suggests that you've misconfigured the ksqlDB server in its connection to Kafka Connect.
If you're following that demo script then you should use the associated Docker Compose file which is configured correctly:
KSQL_KSQL_CONNECT_URL: http://kafka-connect-01:8083
Issue while connecting to Postgres/Greenplum.
org.postgresql.util.PSQLException: An error occurred while setting up the GSS Encoded connection.
I am using same connection file and was working fine till postgres 11/Greenplum v5.0
PostgreSQL 12 and later now allow GSSAPI encrypted connections. This parameter controls whether to enforce using GSSAPI encryption or not.
If encryption is not configured, should be disabled by setting JDBC connection parameter
gssEncMode=disable
Ref: https://www.ibm.com/support/pages/node/6323207
I am upgrading my heroku database from a hobby dev to Standard 0 (using the official instructions https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases#upgrade-with-pg-copy-default).
All went well, until I promoted the new database and restarted the app. I then get the following error:
o.s.boot.SpringApplication : Application startup failed
...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource
...
Caused by: org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource
...
Caused by: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "54.xxx.xx.xxx", user "u94bf9vxxxxxx", database "d2mqk0b6xxxxxx", SSL off
...
If I swap back to the old database again, everything works again. The only thing that I am changing is the promoted database.
Is there a difference between connecting to hobby and standard databases that I need to be aware of?
The relevant part of my application.yml looks as follows:
spring:
datasource:
driverClassName: org.postgresql.Driver
url: ${JDBC_DATABASE_URL}
username: ${JDBC_DATABASE_USERNAME}
password: ${JDBC_DATABASE_PASSWORD}
flyway:
enabled: true
locations: classpath:db/migrations
Any suggestions on how I can debug this would be very welcome too.
Looks like you aren't connecting with SSL where it is required by Heroku PostgreSQL installs.
See Herokus documentation on SSL for PostgreSQL.
See also Herokus documentation for enabling SSL on JDBC connections.
You will need to add something like &ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory to your JDBC URL.