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

rewriteBatchedStatements causes "QueryException: [...] error in your SQL syntax"

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.5.0-RC
    • 1.5.1-RC
    • Other
    • None

    Description

      When using rewriteBatchedStatements=true a java.sql.PreparedStatement containing parentheses around the '?' placeholders will fail. It will throw org.mariadb.jdbc.internal.util.dao.QueryException: You have an error in your SQL syntax; check the manual...

      Demonstration is included below.
      This was tested using mariadb-java-client-1.5.0-RC1.jar

       
      public class RewriteBatchedStatementsTest2 {
      	public static void main(String[] args) throws SQLException {
      		String url = "jdbc:mariadb://localhost:3306/information_schema?rewriteBatchedStatements=true";
      		Connection conn = DriverManager.getConnection(url, "root", "");
      		try {
      			String failingQuery1 = "SELECT (1=? AND 2=2)";
      			String failingQuery2 = "SELECT (1=?) AND 2=2";
      			String workingQuery = "SELECT 1=? AND (2=2)";
      			PreparedStatement statement = conn.prepareStatement(failingQuery1);
      			try {
      				statement.setInt(1, 1);
      				statement.executeQuery();
      			} finally {
      				statement.close();
      			}
      		} finally {
      			conn.close();
      		}
      	}
      }
      
      

      Attachments

        Activity

          jaapbeetstra Jaap Beetstra created issue -
          diego dupin Diego Dupin made changes -
          Field Original Value New Value
          Fix Version/s 1.5.1-RC [ 22121 ]
          diego dupin Diego Dupin made changes -
          Component/s Other [ 12201 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 76620 ] MariaDB v4 [ 134892 ]

          People

            diego dupin Diego Dupin
            jaapbeetstra Jaap Beetstra
            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.