Kr Younger 6 years ago
parent
commit
9145fd6fb3

+ 0
- 1
application.properties View File

@@ -1 +0,0 @@
1
-spring.datasource.url=${DATABASE_URL}

+ 0
- 53
src/main/java/com/example/throwupthursday/config/DatabaseConfig.java View File

@@ -1,53 +0,0 @@
1
-package com.example.throwupthursday.config;
2
-
3
-import org.springframework.boot.context.properties.ConfigurationProperties;
4
-import org.springframework.boot.jdbc.DataSourceBuilder;
5
-import org.springframework.context.annotation.Bean;
6
-import org.springframework.context.annotation.Configuration;
7
-import org.springframework.context.annotation.Primary;
8
-
9
-import javax.sql.DataSource;
10
-
11
-@Configuration
12
-public class DatabaseConfig {
13
-    @Bean
14
-    @Primary
15
-    @ConfigurationProperties(prefix = "spring.datasource")
16
-    public DataSource dataSource() {
17
-        return DataSourceBuilder.create().build();
18
-    }
19
-
20
-//    Logger log = LoggerFactory.getLogger(getClass());
21
-//
22
-//    @Bean
23
-//    @Profile("postgres")
24
-//    public DataSource postgresDataSource() {
25
-//        String databaseUrl = System.getenv("DATABASE_URL")
26
-//        log.info("Initializing PostgreSQL database: {}", databaseUrl);
27
-//
28
-//        URI dbUri;
29
-//        try {
30
-//            dbUri = new URI(databaseUrl);
31
-//        }
32
-//        catch (URISyntaxException e) {
33
-//            log.error(String.format("Invalid DATABASE_URL: %s", databaseUrl), e);
34
-//            return null;
35
-//        }
36
-//
37
-//        String username = dbUri.getUserInfo().split(":")[0];
38
-//        String password = dbUri.getUserInfo().split(":")[1];
39
-//        String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':'
40
-//                + dbUri.getPort() + dbUri.getPath();
41
-//
42
-//        org.apache.tomcat.jdbc.pool.DataSource dataSource
43
-//                = new org.apache.tomcat.jdbc.pool.DataSource();
44
-//        dataSource.setDriverClassName("org.postgresql.Driver");
45
-//        dataSource.setUrl(dbUrl);
46
-//        dataSource.setUsername(username);
47
-//        dataSource.setPassword(password);
48
-//        dataSource.setTestOnBorrow(true);
49
-//        dataSource.setTestWhileIdle(true);
50
-//        dataSource.setTestOnReturn(true);
51
-//        dataSource.setValidationQuery("SELECT 1");
52
-//        return dataSource;
53
-}