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()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 2.3.0, 2.2.6
    • 2.4.0
    • protocol
    • 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

              diego dupin Diego Dupin
              divus Leonid M.
              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.