我遇到了与Redshift的JDBC连接问题,我无法解决这个问题。使用文档中给出的示例,当用户使用普通密码时,我可以轻松连接到Redshift群集,但当用户的密码中包含#字符时,我会收到身份验证失败。我可以使用两组凭据使用SQL Workbench / J连接到集群。当我使用以下内容时,没有连接问题。
DriverManager.setLoginTimeout(60);
Properties props = new Properties();
props.setProperty("user", "johndoe");
props.setProperty("password", "superSecret");
props.setProperty("tcpKeepAlive", "true");
Connection connection = DriverManager.getConnection("jdbc:redshift://xxxxxxx.us-east-1.redshift.amazonaws.com:5439/dev", props);
当我使用以下内容时,
DriverManager.setLoginTimeout(60);
Properties props = new Properties();
props.setProperty("user", "johndoehash");
props.setProperty("password", "superDouble#Secret");
props.setProperty("tcpKeepAlive", "true");
Connection connection = DriverManager.getConnection("jdbc:redshift://xxxxxxx.us-east-1.redshift.amazonaws.com:5439/dev", props);
我收到了身份验证错误
java.sql.SQLException: [Amazon](500310) Invalid operation: password authentication failed for user "johndoehash";
at com.amazon.redshift.client.messages.inbound.ErrorResponse.toErrorException(ErrorResponse.java:1830)
at com.amazon.redshift.client.InboundDataHandler.read(InboundDataHandler.java:454)
at com.amazon.support.channels.AbstractSocketChannel.readCallback(Unknown Source)
at com.amazon.support.channels.PlainSocketChannel.read(Unknown Source)
Caused by: com.amazon.support.exceptions.ErrorException: [Amazon](500310) Invalid operation: password authentication failed for user "johndoehash";
我可以使用SQL Workbench / J使用这两个帐户登录到群集但由于某种原因我无法通过我的应用程序进行连接。关于我做错什么的任何想法?
答案 0 :(得分:0)
我没有足够的评论意见。我不知道这是否能解决您的问题。但试试这个:
props.setProperty(“password”,“superDouble# Secret”);
没有“&”之间的空格和“#35;”
可选地
props.setProperty(“password”,“superDouble%23Secret”);
答案 1 :(得分:0)
这真的很奇怪,但如果我在我的应用程序中使用Java 8的旧版本
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
问题消失了......去看看。