Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-934

MariaDbDataSource is sensitive to the order of setting of username and password

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.3
    • Fix Version/s: 3.0.4
    • Component/s: configuration
    • Labels:
      None
    • Environment:
      Payara 5.2022.1
      OpenJDK 11.0.5
      Fedora Core 29

      Description

      If the password happens to be set first before the user then the connection will fail.

      The problem occurs in the config() method...

        private void config() throws SQLException {
          if (url == null) throw new SQLException("url not set");
          conf = Configuration.parse(url);
          if (loginTimeout != null) conf.connectTimeout(loginTimeout * 1000);
          if (user != null) {
            conf = conf.clone(user, password);
          } else {
            user = conf.user();
            password = conf.password();
          }
        }
      

      If the password is set before the user (i.e. user is null when config() is called) then the statement

            password = conf.password();
      

      overwrites the password with null (assuming that there is no password in the URL).
      Any subsequent call to getConnection() will likely fail because the connection will be attempted without a password.

      In Payara/Glassfish the order of setting of the connection properties is governed by the code in com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject() which uses reflection to discover the driver's properties. The methods are invoked in the (arbitrary) order of discovery, so the order is not controllable by the user.
      It depends on what the eventual result should be as to what the solution is. Should parameters in the URL take precedence over explicit property settings?

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            Selwyn Chris Selwyn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.