title: What is useLocalSessionState used for?
body: <p>I had an issue with MySQL db where the setAutocommit were being logged many times even though there was no autocommit mode change. For example, if I call setautocommit(false) 5 times, I see 5 queries in the query log saying set autommit=0; </p>
  
  <p>This is usually not supposed to happen as the autocommit mode hasnt changed. The query should be sent only when I am changing the autocommit mode i.e. say 1 to 0.</p>
  
  <p>When I did some looking in the MySQL connection class implementation, I figured that they check useLocalSessionState value to decide whether they want to execute the query or not?</p>
  
  <pre><code> if ((getUseLocalSessionState()) &amp;&amp; (this.autoCommit == autoCommitFlag)) {
              needsSetOnServer = false;
            }
  </code></pre>
  
  <p>So, even though this.autocommit &amp; autocommit flag are same, needsSetOnServer is NOT set to false becuase useLocalSessionState is defaulted to false. </p>
  
  <p>Once I add useLocalSessionState = true in my connection URL, I dont see the unnecessary query logs. </p>
  
  <p>So, my questions are :</p>
  
  <ol>
  <li>What is the significance of useLocalSessionState ? Why is it used generally?</li>
  <li>Is it safe to set useLocalSessionState = true?</li>
  </ol>
  
  <p>PS : I see that SQL Server handles this kind of a scenario without any such dependencies i.e. (Code snippet from SQLServerConnection</p>
  
  <pre><code>if (paramBoolean == this.databaseAutoCommitMode) {
        return;
      }
  </code></pre>