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

SQLException when backslash (\), which doesn't escape any character, is used together with setParameter()

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0, 2.2.6
    • Fix Version/s: 2.4.0
    • Component/s: protocol
    • Labels:
      None

      Description

      In the following description it is not possible to write two backslashes after each other. That's why I wrote '\ \' with space between in meaning two following backslashes without space.

      Commit https://github.com/MariaDB/mariadb-connector-j/commit/e9e8acc400d5935082b9d4d5255d5e735eae7a8f
      causes problems if SELECT or WHERE contains backspace(s) without following ' or "
      Simple Select doesn't work any more without ...?sessionVariables=sql_mode=NO_BACKSLASH_ESCAPES
      getSession().createSQLQuery("SELECT CONCAT('\\\\', '') FROM (SELECT '') AS a WHERE :q = 1").setParameter("q", 1).list();

      Caused by: java.sql.SQLException: Could not set parameter at position 1 (values was 1)
      Query - conn:1180011(M) - "SELECT CONCAT('\ \', '') FROM (SELECT '') AS a WHERE ? = 1"
      at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getSqlException(ExceptionMapper.java:211)
      at org.mariadb.jdbc.MariaDbPreparedStatementClient.setParameter(MariaDbPreparedStatementClient.java:438)
      at org.mariadb.jdbc.BasePrepareStatement.setInt(BasePrepareStatement.java:1436)
      ...

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                diego dupin Diego Dupin
                Reporter:
                divus Leonid M.
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: