这是我的连接网址:
jdbc:mysql://mydbhost:3306/mydatabase?user=username&password=%u16*!ypK@WrUQbr
当我打电话
DriverManager.getConnection()
使用当前URL,我正在捕获异常:
ava.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "u1"
如果连接URL不包含%,则一切正常。
我已找到有关此问题的一些信息,并建议进行下一次转换:
replaceAll("%(?![0-9a-fA-F]{2})", "%25")
通过这种转换,我有错误:
Access denied for user(incorrect password)
有人可以帮助正确转换网址吗?
请在下面的字符串中尝试一下,其中密码中的所有保留字符都将替换为相应的百分比编码值:
% : %25
* : %2A
! : %21
@ : %40
"jdbc:mysql://mydbhost:3306/mydatabase?user=username&password=%25u16%2A%21ypK%40WrUQbr"
有关百分比编码的Wikipedia的更多信息
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句