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

mariadb jdbc client 1.0.0 throws ArrayIndexOutOfBoundsException when passing empty connection url parameter values

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • None
    • 1.1.0
    • None
    • None
    • Mac OS X 10.7.5, java 1.6.0_37, using mariadb-client-1.0.0 (with MySQL 5.1.66)

    Description

      The following code fails:

      DriverManager.getConnection("jdbc:mysql//localhost:3306/test?user=root&password=");

      throws:

      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
      at org.mariadb.jdbc.Driver.setURLParameters(Driver.java:128)
      at org.mariadb.jdbc.Driver.connect(Driver.java:103)
      at java.sql.DriverManager.getConnection(DriverManager.java:582)
      at java.sql.DriverManager.getConnection(DriverManager.java:207)

      Here is a proposed patch for Driver.setURLParameters:

      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("Expected key=value: " + param); }

      info.setProperty(param.substring(0, pos), param.substring(pos + 1));
      }
      }

      Attachments

        Activity

          People

            wlad Vladislav Vaintroub
            bjornm Bjorn Melinder (Inactive)
            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.