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

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.1.7
    • 1.1.8
    • None
    • 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

            massimo.siani Massimo Siani (Inactive)
            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.