title: mysql user-defined variable concurrency in connection pool?
body: <p>In mysql we use @ for user-defined variable, which stays alive until the connection is closed. In java, when multiple threads share one connection pool, while calling a stored procedure concurrently to get rankings:</p>
  
  <pre><code>BEGIN
    SET @rank := 0;
    SELECT @rank := @rank + 1 as rank FROM ...
  END
  </code></pre>
  
  <p>If 2 threads are calling the procedure at same time, without synchronizing @rank, is it possible @rank may return unexpected result? </p>
  
  <p>Is there a better way to handle this situation?</p>
  
  <p>Thanks!</p>