|
5 | 5 | import org.slf4j.LoggerFactory; |
6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
7 | 7 | import org.springframework.beans.factory.annotation.Value; |
8 | | -import org.springframework.cloud.servicebroker.model.ServiceInstance; |
9 | 8 | import org.springframework.jdbc.core.JdbcTemplate; |
10 | | -import org.springframework.jdbc.datasource.DriverManagerDataSource; |
11 | 9 | import org.springframework.jdbc.datasource.SingleConnectionDataSource; |
12 | 10 | import org.springframework.stereotype.Component; |
13 | | - |
14 | 11 | import javax.annotation.PostConstruct; |
15 | 12 | import javax.validation.constraints.NotNull; |
16 | 13 | import java.math.BigInteger; |
17 | | -import java.net.URI; |
18 | 14 | import java.security.SecureRandom; |
19 | 15 | import java.sql.*; |
20 | 16 | import java.util.Collections; |
@@ -221,16 +217,18 @@ public String bindRoleToDatabase(String serviceInstanceId, String bindingId) thr |
221 | 217 | //executeUpdate("ALTER DEFAULT PRIVILEGES FOR ROLE \""+serviceInstanceId+"\" IN SCHEMA public GRANT ALL ON SEQUENCES TO \"" + bindingId + "\""); |
222 | 218 | //executeUpdate("ALTER DEFAULT PRIVILEGES FOR ROLE \""+serviceInstanceId+"\" IN SCHEMA public GRANT ALL ON FUNCTIONS TO \"" + bindingId + "\""); |
223 | 219 |
|
224 | | - |
225 | | - URI uri = new URI(jdbcTemplate.getDataSource().getConnection().getMetaData().getURL().replace("jdbc:", "")); |
226 | | - |
| 220 | + // Support multi-proxy |
| 221 | + String uri = jdbcTemplate.getDataSource().getConnection().getMetaData().getURL().replace("jdbc:postgresql://", "").split("/")[0]; |
| 222 | + String dbURL = String.format("postgres://%s:%s@%s/%s",serviceInstanceId, findServiceInstance(serviceInstanceId).getCredentials(), uri , serviceInstanceId); |
| 223 | + /* |
227 | 224 | String dbURL = String.format("postgres://%s:%s@%s:%d/%s", |
228 | 225 | // hack for multibinding |
229 | 226 | serviceInstanceId, |
230 | 227 | findServiceInstance(serviceInstanceId).getCredentials(), |
231 | 228 | //bindingId, passwd, |
232 | 229 | uri.getHost(), uri.getPort() == -1 ? 5432 : uri.getPort(), serviceInstanceId); |
233 | | - |
| 230 | + |
| 231 | + */ |
234 | 232 | return dbURL; |
235 | 233 | } |
236 | 234 |
|
|
0 commit comments