Thursday, July 16, 2015

Spring Boot with non JDBC database url

Using Spring Boot a DataSource usually is configured using spring.datasource.* properties as shown in the following example:

However database as a service providers (like Heroku Postgres, Compose PostgreSQL, ClearDB MySQL) provide the connection parameters in a format of
Would be nice to have a single URI property in Spring Boot to configure database connection properties, similar how we can configure a MongoDB connection via or a Redis connection via spring.redis.uri

Below you find how you could use a single URI property, in this case spring.datasource.uri to specify the database connection parameters to a Heroku PostgreSQL database service. The demo application is running on Heroku and using three datastore services:

The connection properties are managed on Heroku:

In the application we just reference the Heroku config variables, encapsulating them in a heroku profile.

Then we just need to extract the connection properties from the spring.datasource.uri and create a DataSource. In this example we use the Tomcat JDBC Connection Pool to create the DataSource instance.

The demo application is available on my github profile.


Jeffy said...

I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

Digital Marketing Company in Chennnai

Saki R said...

nice blog too informative. looking and reading your points its so impressive. doing more blog like this. i really appreciated doing like this.
Java Training in Chennai

Saki R said...

this is really too useful and have more ideas from yours. keep sharing many techniques. eagerly waiting for your new blog and useful information. keep doing more.

Java Training in Chennai

Vignesh PV said...

Wonderful blog.. Thanks for sharing informative blog.. its very useful to me.. android Training in Chennai

Abiya Carol said...

I just see the post i am so happy the post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be subscribing to your feed and I hope you post again soon.

SEO Training in Chennai

Philips Huges said...

Wonderful blog.. Thanks for sharing informative Post. Its very useful to me.

Installment loans
Payday loans
Title loans

Rajasekar L said...

Thank you for taking the time to provide us with your valuable information.
Freshers Jobs in Chennai

Priya B said...

Thank you for taking the time to provide us with your valuable information. Best Android Training in Velachery

ramya zuan said...
This comment has been removed by the author.
Ahkansha said...

The blog was interesting and It is excellent. The article is giving to valuable informative. thanks for sharing your article. It is really great post and getting some ideas for new blog post.
java training in chennai

Ancy merina said...

What a fantastic and informative blog! i enjoyed reading this, and I must say your blog is great! Keep up the excellent work. You have a magical talent of holding readers mind.
Web Development Services in Bangalore
BEST web design services in bangalore
ECommerce Website developers in bangalore
Outsource magento ecommerce services india