package net.nhs.repo.legacy.config;

import javax.sql.DataSource;

import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

@Configuration
public class LegacyDataConfig {

	@Autowired
	private Environment environment;

	@Bean(destroyMethod="close")
	public DataSource legacyDataSource() {

		BasicDataSource dataSource = new BasicDataSource();
		dataSource.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
		dataSource.setUrl("jdbc:mysql://localhost:3306/poc_legacy");
		dataSource.setUsername("root");
		dataSource.setPassword(null);
		return dataSource;
	}

}

@@ -504,16 +504,298 @@
 ce() %7B%0A%0A
+%09%09String envConfig = System.getenv(%22CLEARDB_DATABASE_URL%22);%0A%0A%09%09URI dbUri = new URI(envConfig);%0A    String username = dbUri.getUserInfo().split(%22:%22)%5B0%5D;%0A    String password = dbUri.getUserInfo().split(%22:%22)%5B1%5D;%0A    String dbUrl = %22jdbc:mysql://%22 + dbUri.getHost() + dbUri.getPath();%0A%0A
 %09%09BasicD
@@ -936,48 +936,13 @@
 Url(
-%22jdbc:mysql://localhost:3306/poc_legacy%22
+dbUrl
 );%0A%09
@@ -969,14 +969,16 @@
 ame(
-%22root%22
+username
 );%0A%09
@@ -1005,15 +1005,20 @@
 ord(
-null
+password
 );%0A
+%0A
 %09%09re

Add heroku db config