Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection url for Oracle and SqlServer #83

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xieshenzh
Copy link

Update the connection url for Oracle and SqlServer that is generated by spring-cloud-bindings.

fixes: #82

@@ -49,7 +49,7 @@ public void process(Environment environment, Bindings bindings, Map<String, Obje
map.from("username").to("spring.datasource.username");
map.from("password").to("spring.datasource.password");
map.from("host", "port", "database").to("spring.datasource.url",
(host, port, database) -> String.format("jdbc:oracle://%s:%s/%s", host, port, database));
(host, port, database) -> String.format("jdbc:oracle:thin:@%s:%s/%s", host, port, database));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I commented in #82 (comment), this is incomplete

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is incomplete. But the old code doesn't work in any scenario. I just changed it to work in certain scenarios.
It is not possible to cover all the scenarios. Users will have to use jdbc-url in these cases.

If it is necessary to cover the three connection types (i.e. SID, Service Name, TNS), which key should the user use to specify the connection type?
If the users don't specify the connection type via service binding, the code will not be able to determine what is the connection type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jdbc:oracle:thin:@%s:%s/%s

Did you mean jdbc:oracle:thin:@//%s:%s/%s (service name) or jdbc:oracle:thin:@%s:%s:%s (sid) ?

I think it's good to introduce new keys connection-type (default sevice name or sid) and driver (default thin)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the code to cover scenarios for sid, service name and tns. Please take a look. Thanks.

@xieshenzh xieshenzh marked this pull request as draft October 3, 2022 04:24
@xieshenzh xieshenzh marked this pull request as ready for review October 5, 2022 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Service binding doesn't work with Oracle and SqlServer
2 participants