how to escape special characters in mysql jdbc connection string

余生长醉 提交于 2019-12-21 20:27:39

问题


im trying to connect to a remote database. im sure that the remote database provide me all the privileges. but im getting this error when trying to connect to the remote mysql database through jdbc connection. my password contains, * and & symbol, i think that is the problem cause to this error. but i dont know how to escape those characters. please help

java.sql.SQLException: Access denied for user 'myusername'@'myhost' (using password: YES)

"jdbc:mysql://myhost/mydb?user=myusername&password=my&password*"

please help

Regards


回答1:


The JDBC connection string is in url format so you must use URL encoded values for all parameters. In your case the connection string should look like:

"jdbc:mysql://myhost/mydb?user=myusername&password=my%26password%2A"


来源:https://stackoverflow.com/questions/13984567/how-to-escape-special-characters-in-mysql-jdbc-connection-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!