【发布时间】:2023-04-05 17:41:01
【问题描述】:
无法使用 jdbc 连接 url 连接到 redshift。
我的密码有特殊字符,例如:a(=b`git.
我的网址是 jdbc:redshift://localhost:5439/trsanalytics?user=user1&password=a%28%3Db%60git
我正在对密码进行编码并附加它。我仍然收到以下错误
Amazon](500310) 无效操作:用户密码验证失败
示例代码sn-p
String encode_pwd = URLEncoder.encode(password,"UTF-8");
String fullUrl = url + "?user=" + username + "&password=" + encode_pwd;
DriverManager.getConnection(url)
【问题讨论】:
-
先试试打印你的密码来测试是否正确。
-
这是正确的,当我通过属性添加时它可以工作。属性 props = new Properties(); props.setProperty("用户", 用户名); props.setProperty("密码", 密码); executeQuery(DriverManager.getConnection(url, props));工作正常
-
尝试使用 encode_pwd.trim();
-
如果它适用于属性,为什么不使用属性呢?在 URL 中提供密码是一个安全问题,因为可以使用
connection.getMetaData().getURL()检索 URL。 -
@Osmore 试试为什么?
标签: java jdbc amazon-redshift urlencode