I'm trying to create a datasource from my Heroku/Spring application to postgres.heroku.com postgres database. Here is my applicationContext.xml
snippet.
<bean id="securityDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://url/dstabase"/>
<property name="username" value="user"/>
<property name="password" value="password"/>
</bean>
But when I run the app, tomcat gives this error:
Cannot create PoolableConnectionFactory (FATAL: no pg_hba.conf entry for host "10.11.12.13", user "username", database "database", SSL off)
How can I configure it to use SSL? I need it in order to stablish a connection against postgres.heroku.com
To create the credential through data.heroku.com, select the Credentials tab and click the Create Credential button. The name should reflect the purpose of the credential. In the above example, limited_user is used as the credential's username when connecting to the database.
You need to extend your JDBC connection URL with the relevant ssl information.
Your JDBC connection URL will need to include the following:
ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
So in your case the URL would be:
jdbc:postgresql://url/dstabase?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
Source for this info: https://devcenter.heroku.com/articles/connecting-to-relational-databases-on-heroku-with-java#connecting-to-a-database-remotely
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With