Skip to content

Commit

Permalink
Merge pull request quarkusio#27467 from xieshenzh/service-binding-sql…
Browse files Browse the repository at this point in the history
…server-oracle

Fix service binding for SqlServer and Oracle
  • Loading branch information
gsmet authored Aug 24, 2022
2 parents c51233e + 9743d7e commit 85d06ba
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class MsSQLServiceBindingConverter implements ServiceBindingConverter {
@Override
public Optional<ServiceBindingConfigSource> convert(List<ServiceBinding> serviceBindings) {
return ServiceBinding.singleMatchingByType("sqlserver", serviceBindings)
.map(new DatasourceServiceBindingConfigSourceFactory.Jdbc());
.map(new DatasourceServiceBindingConfigSourceFactory.Jdbc("jdbc:%s://%s%s;databaseName=%s"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class OracleServiceBindingConverter implements ServiceBindingConverter {
@Override
public Optional<ServiceBindingConfigSource> convert(List<ServiceBinding> serviceBindings) {
return ServiceBinding.singleMatchingByType("oracle", serviceBindings)
.map(new DatasourceServiceBindingConfigSourceFactory.Jdbc());
.map(new DatasourceServiceBindingConfigSourceFactory.Jdbc("jdbc:%s:thin:@%s%s/%s"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.quarkus.jdbc.oracle.runtime.OracleServiceBindingConverter
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ private Map<String, String> getServiceBindingProperties() {
log.debugf("Property 'password' was not found for datasource of type %s", serviceBinding.getType());
}

String url = bindingProperties.get("jdbc-url");
if (url != null) {
properties.put(urlPropertyName, url);
return properties;
}

String host = bindingProperties.get("host");
String port = bindingProperties.get("port");
String database = bindingProperties.get("database");
Expand All @@ -72,11 +78,19 @@ public static class Jdbc extends DatasourceServiceBindingConfigSourceFactory {
public Jdbc() {
super("jdbc", "quarkus.datasource.jdbc.url", "jdbc:%s://%s%s/%s");
}

public Jdbc(String urlFormat) {
super("jdbc", "quarkus.datasource.jdbc.url", urlFormat);
}
}

public static class Reactive extends DatasourceServiceBindingConfigSourceFactory {
public Reactive() {
super("reactive", "quarkus.datasource.reactive.url", "%s://%s%s/%s");
}

public Reactive(String urlFormat) {
super("reactive", "quarkus.datasource.reactive.url", urlFormat);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class OracleServiceBindingConverter implements ServiceBindingConverter {
@Override
public Optional<ServiceBindingConfigSource> convert(List<ServiceBinding> serviceBindings) {
return ServiceBinding.singleMatchingByType("oracle", serviceBindings)
.map(new DatasourceServiceBindingConfigSourceFactory.Reactive());
.map(new DatasourceServiceBindingConfigSourceFactory.Reactive("%s:thin:@%s%s/%s"));
}

}

0 comments on commit 85d06ba

Please sign in to comment.