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

Session variables lost and exception if set via MySQLDataSource.setProperties/setURL

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.7
    • Fix Version/s: 1.1.8
    • Component/s: None
    • Labels:
      None

      Description

      If I set session variables via the MySQLDataSource.setProperties method (or indirectly with setURL), the value of the 'sessionVariables' parameter is not picked up correctly.
      I use:

      dataSource.setProperties("sessionVariables=sql_mode='PIPES_AS_CONCAT'")

      The current implementation of this method is:

      public void setProperties(String properties) {
        String[] parameters = properties.split("&");
        for (String param : parameters) {
          String[] keyVal = param.split("=");
          this.info.setProperty(keyVal[0], keyVal[1]);
        }
      }

      which leads to the property 'sessionVariables' with value 'sql_mode'.
      The entire text after sql_mode is lost and creating a connection to the database throws an exception.

      The implementation of parsing properties in the class Driver is correct:

      private void setURLParameters(String urlParameters, Properties info)
      {
        String[] parameters = urlParameters.split("&");
        for (String param : parameters) {
          int pos = param.indexOf('=');
          if (pos == -1) {
            throw new IllegalArgumentException("Invalid connection URL, expected key=value pairs, found " + param);
          }
          info.setProperty(param.substring(0, pos), param.substring(pos + 1));
        }
      }

        Attachments

          Activity

            People

            Assignee:
            massimo.siani Massimo Siani (Inactive)
            Reporter:
            Jovel J. Veldhuizen
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.