JDBC URL & special character support

Hello,

Is there a way to use a password with & character in the JDBC URL with MariaDB connector? The version of the connector used is 2.7.2.

Thanks.

Answer Answered by Diego Dupin in this comment.

That's not possible in connection string.

Solution are to use DriverManager, like :

    try (Connection con = DriverManager.getConnection(
            "jdbc:mariadb://localhost:3306/db", 
            "myUser", 
            "MyPw&d")) {
      ...
    }

or with properties :

    Properties properties = new Properties();
    properties.getProperty("user", "myUser");
    properties.getProperty("password", "MyPw&d");

    try (Connection con = DriverManager.getConnection(
            "jdbc:mariadb://localhost:3306/db", 
            properties)) {
      ...
    }

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.