Kr Younger 6 lat temu
rodzic
commit
f1b68bfd1a

+ 6
- 1
application.properties Wyświetl plik

@@ -1,5 +1,10 @@
1 1
 spring.datasource.driverClassName=org.postgresql.Driver
2
-spring.datasource.jdbcUrl=jdbc:postgresql://rewhzisjvghccm:7729c91fdd0d43e313bd3d0f6c68e0a1389b7c004c92591d0c8d7e9348d23a81@ec2-23-23-247-222.compute-1.amazonaws.com:5432/dau244akoqlr9g
2
+spring.datasource.url=${JDBC_DATABASE_URL}
3
+spring.datasource.username=${JDBC_DATABASE_USERNAME}
4
+spring.datasource.password=${JDBC_DATABASE_PASSWORD}
5
+spring.jpa.show-sql=false
6
+spring.jpa.generate-ddl=true
7
+spring.jpa.hibernate.ddl-auto=update
3 8
 spring.datasource.maxActive=10
4 9
 spring.datasource.maxIdle=5
5 10
 spring.datasource.minIdle=2

+ 34
- 0
src/main/java/com/example/throwupthursday/config/DatabaseConfig.java Wyświetl plik

@@ -16,4 +16,38 @@ public class DatabaseConfig {
16 16
     public DataSource dataSource() {
17 17
         return DataSourceBuilder.create().build();
18 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;
19 53
 }