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

PreparedStatement.setObject() returns IllegalParameterException: No '?' on that position

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.1.7
    • 1.1.8
    • None
    • None
    • Java 8, MariaDB connector 1.1.7 remotely connected to MariaDB server 10.0.11-MariaDB

    Description

      The query below works fine with MySQL Connector/J driver. But it produces IllegalParameterException with mariaDB Java driver. The server is MariaDB in both cases.

      The query:
      REPLACE INTO tblCustomerUDf1 (`BestPracticesNotification`,`SLIndex#orBV#`,`Seems:LikeParam?`,`Webinar1-3QuickSteps`,`Webinar10-TM/ProjComp`,`Webinar2-MSSelling`,`Webinar3-ProductSelling`,`Webinar4-TM/ProjSelling`,`Webinar5-MSDelivery`,`Webinar6-ProductDelivery`, `isM&M'sTasty?`) VALUES (?,?,?,?,?,?,?,?,?,?,?).

      The relevant part of stack trace:
      org.mariadb.jdbc.internal.common.query.IllegalParameterException: No '?' on that position
      at org.mariadb.jdbc.internal.common.query.MySQLParameterizedQuery.setParameter(MySQLParameterizedQuery.java:103)
      at org.mariadb.jdbc.MySQLPreparedStatement.setParameter(MySQLPreparedStatement.java:477)
      ... 89 more

      Removing columns with '#' or '?' in names solves the problem. But this is the fail of the driver as MariaDB server legally supports such characters in column names.

      After some debugging I figured out that PS parser does not distinguish back-ticks enclosing column names. So it interprets '#' in the column name `SLIndex#orBV#` as a start of the comment. When I remove this column the parser detects parameter placeholder '?' inside the column name `Seems:LikeParam?` etc.

      So the parser needs to be improved to respect back-ticks around object names.

      The problematic method is org.mariadb.jdbc.internal.common.Utils::createQueryParts

      The test table:
      CREATE TABLE IF NOT EXISTS `tblCustomerUDf1` (
      `customerID1` int(11) NOT NULL,
      `BestPracticesNotification` text,
      `SLIndex#orBV#` text,
      `isM&M'sTasty?` bit(1) DEFAULT NULL,
      `Seems:LikeParam?` bit(1) DEFAULT NULL,
      `Webinar1-3QuickSteps` text,
      `Webinar2-MSSelling` text,
      `Webinar3-ProductSelling` text,
      `Webinar4-TM/ProjSelling` text,
      `Webinar10-TM/ProjComp` text,
      `Webinar5-MSDelivery` text,
      `Webinar6-ProductDelivery` text

      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

      Thank you,
      Ivan

      Attachments

        Activity

          People

            massimo.siani Massimo Siani (Inactive)
            petrichenko@gmail.com Ivan
            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.