|
@@ -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
|
}
|