-
Notifications
You must be signed in to change notification settings - Fork 348
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
Redshift password in connection string can't be illegal-URL characters #132
Comments
Looks like the URI is only instantiated to get at the schema, so an easy fix is to just ditch the parameters before passing it in. Is this an ok fix? Should I PR? |
I guess that not all valid JDBC connection strings are valid URIs? If that's the case, then modifying this code to not use the URI-parsing code for extracting the subprotocol seems like a fine approach (we could just use a regex). Feel free to submit a PR for this and I'll be happy to review. |
This was fixed by #134. Thanks @tristanreid! |
Hey guys, Has this been put into any released version? I'm having issues connecting to Redshift because my password has special characters. I've tried wrapping in quotes, and even encodedPass = URLEncoder.encode(password). It seems that no matter how I try to encode I'm receiving: |
Hi @jamesjgardner, This patch was included in the 0.6.0 release: /~https://github.com/databricks/spark-redshift/releases/tag/v0.6.0 Which version of |
Hi @JoshRosen, I'm using: And doing a simple URLEncoder to clean up the password. |
I can try to test this out on my own Redshift instance later, but to help me debug it would be really helpful if you could confirm whether your |
I tried about every combination of URI encoding and different parameter names e.g. UID and PWD are also used by redshift to no avail. I ended up just creating another user with a password without a bunch of special characters and it works fine. I would greatly appreciate it if I could get an update if this get's worked out. You might want to see if you can get it to work on a password with an "=" in it. |
I just confirmed that my earlier fix no longer works - using the same jar that I made before, and same JDBC driver. I am able to use the same password to connect via SQLJWorkbench using the exact same JDBC driver. Weird. I'll take a look at troubleshooting this. |
I've re-opened this issue to track it for 0.6.1. |
Thanks! James
|
Alright - now I don't know how this succeeded previously - it clearly doesn't work. I just wrote some straight JDBC code, and I can show that it works when you set username/password as properties, but not when you put them into the URL of the connection string. Compile this with The output is that the first connection succeeds, and the second fails with password authentication error. I propose to change the
|
Here's an example: tristanreid@d3ab1db I just tested this, and it works. I think the scala is stylistic a little ugly. If this approach is ok I'd welcome feedback on that? |
Here's my initial thoughts:
Therefore, I have the following proposal:
I don't think we should try the more complex "parse the password out of the URI with string manipulation" approach, since it seems harder to test and reason about and seems somewhat nonstandard. |
So to ensure I understand: if creds are passed in the URI, use the existing logic, not the parsing? I think that's the simplest approach, and parallels what would happen in other environments. |
Yep, that's right. |
Almost done: tristanreid@8fe5c13 Where's the best place to add the unit test? |
If it was me, I'd probably add a |
Per #132, this PR adds user and password options. If these options are present and the user/password are still in the URL, an exception is thrown with a clear error message. Unit tests are still pending - maybe it's better to check for ambiguous parameters in the Parameter class instead, to make it easier to test? Glad for any other feedback as well! Author: Tristan Reid <tristan@datascience.com> Closes #162 from tristanreid/master.
Going to mark this as fixed now that #162 has been merged. |
When I put the user / password in the jdbc url I get a authentication failure, my password contains the following special characters: ?! When I use the user and password options I get the error below:
I am using the latest release in java
Any help would be appreciated. |
If you have a password with a carat or question mark, fails with 'Illegal character'
If you have a percentage sign, you get 'Malformed escape pair at index...'
If I urlencode my password parameter I just get
java.sql.SQLException: [Amazon](500150) Error setting/closing connection: password authentication failed for user "me"
Is there a way around this?
Thanks in advance, apologies if I'm missing something obvious
The text was updated successfully, but these errors were encountered: