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
You need to extend your JDBC connection URL with the relevant ssl information.
Your JDBC connection URL will need to include the following:
So in your case the URL would be:
Source for this info:
https://devcenter.heroku.com/articles/connecting-to-relational-databases-on-heroku-with-java#connecting-to-a-database-remotely