title: MySql connector j allow user variables
body: <p>Please help me to find out how to allow mysql connector j to define user variables and make this code valid:</p>
  
  <pre><code>    Statement s = conn.createStatement();
      s.executeQuery ("set @categoryId := (Select CategoryId from categories order by CategoryId desc LIMIT 1);\n" +
                          "set @categoryId := IF(@categoryId is Null, 1, @categoryId);");
  </code></pre>
  
  <p>now it throws an exception:</p>
  
  <pre><code>MySQLSyntaxErrorException occured : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'set @categoryId := IF(@categoryId is Null, 1, @categoryId)' at line 2
  </code></pre>
  
  <p>I know that in .net you can define "Allow User Variables = true" option in connection string. How to do it in java?</p>