Comments - JDBC URL & special character support

2 years, 11 months ago Diego Dupin

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)) {
      ...
    }

 
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.