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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.0-RC
    • Fix Version/s: 1.5.1-RC
    • Component/s: Other
    • Labels:
      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

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            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.