title: Sonar fails to connect to mysql, running from gradle
body: <p>I have a sonar configuration that looks like this: </p>
  
  <pre><code>sonar.jdbc.username=sonar
  sonar.jdbc.password=sonar
  sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncod$
  sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
  sonar.jdbc.validationQuery=select 1
  
  sonar.web.host=127.0.0.1
  sonar.web.context=/sonar
  sonar.web.port=9000
  </code></pre>
  
  <p>And when running this from my gradle script, which looks  like this: </p>
  
  <pre><code>  sonarProperties {
  
          property "sonar.projectKey", "sonar-example"
          property "sonar.projectName", "sonar example"
          property "sonar.projectVersion", "1.0"
  
          property "sonar.sources", "src/main/java"
          property "sonar.binaries", "build"
          property "sonar.test", "src/test/java"
  
          property "sonar.language", "java"
          property "sonar.profile", "Android Lint"
          property "sonar.android.lint.report", "lint-report.xml"
          property "sonar.dynamicAnalysis", "reuseReports"
          property "sonar.sourceEncoding", "UTF-8"
  
          property "sonar.junit.reportsPath", "build/outputs/reports/coverage/debug"
          property "sonar.cobertura.reportPath", "build/outputs/reports/coverage/debug/cobertura.xml"
          property "sonar.java.coveragePlugin", "cobertura"
  
          property "sonar.host.url", "http://localhost:9000/sonar"
          property "sonar.jdbc.username", "sonar"
          property "sonar.jdbc.password", "sonar"
  
      }
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>pepes-MacBook-Pro-4:android-robolectric-test pepe$ ./gradlew sonarRunner
  :app:sonarRunner
  SonarQube Runner 2.3
  Java 1.7.0_75 Oracle Corporation (64-bit)
  Mac OS X 10.10.3 x86_64
  INFO: Runner configuration file: NONE
  INFO: Project configuration file: /Users/pepe/development/android-robolectric-test/app/build/tmp/sonarRunner/sonar-project.properties
  INFO: Default locale: "sv_SE", source code encoding: "UTF-8"
  INFO: Work directory: /Users/pepe/development/android-robolectric-test/app/build/sonar
  INFO: SonarQube Server 5.0.1
  10:24:55.133 INFO  - Load global referentials...
  10:24:55.406 INFO  - Load global referentials done: 276 ms
  10:24:55.410 INFO  - User cache: /Users/pepe/.sonar/cache
  10:24:55.418 INFO  - Install plugins
  10:24:55.428 INFO  - Download sonar-findbugs-plugin-2.4.jar
  10:24:55.545 INFO  - Download sonar-cpd-plugin-5.0.1.jar
  10:24:55.552 INFO  - Download sonar-scm-git-plugin-5.0.1.jar
  10:24:55.608 INFO  - Download sonar-core-plugin-5.0.1.jar
  10:24:55.615 INFO  - Download sonar-java-plugin-2.8.jar
  10:24:55.675 INFO  - Download sonar-scm-svn-plugin-5.0.1.jar
  10:24:55.679 INFO  - Download sonar-l10n-en-plugin-5.0.1.jar
  10:24:55.683 INFO  - Download sonar-email-notifications-plugin-5.0.1.jar
  10:24:55.736 INFO  - Install JDBC driver
  10:24:55.740 INFO  - Download mysql-connector-java-5.1.27.jar
  10:24:55.753 INFO  - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
  INFO: ------------------------------------------------------------------------
  INFO: EXECUTION FAILURE
  INFO: ------------------------------------------------------------------------
  Total time: 3.580s
  Final Memory: 7M/245M
  INFO: ------------------------------------------------------------------------
  ERROR: Error during Sonar runner execution
  ERROR: Unable to execute Sonar
  ERROR: Caused by: Fail to connect to database
  ERROR: Caused by: Cannot create PoolableConnectionFactory (Connection is broken: "java.net.ConnectException: Connection refused: localhost" [90067-176])
  ERROR: Caused by: Connection is broken: "java.net.ConnectException: Connection refused: localhost" [90067-176]
  ERROR: Caused by: Connection refused
  ERROR:
  ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
  ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
  :app:sonarRunner FAILED
  
  FAILURE: Build failed with an exception.
  </code></pre>
  
  <p>Why is it connecting to H2 and not mysql? I've read the post with the same problem <a href="https://stackoverflow.com/questions/17102025/sonar-not-connecting-to-mysql-db">here</a> and <a href="https://stackoverflow.com/questions/29480744/sonar-fails-to-connect-to-mysql-always-tries-jdbch2tcp-localhost-sonar">here</a>, but the solution seems to have been something related to Maven. I don't use Maven, I use Gradle instead.</p>
  
  <p>EDIT: </p>
  
  <p>property "sonar.jdbc.url", "jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8&amp;rewriteBatchedStatements=true&amp;useConfigs=maxPerformance"</p>
  
  <p>should be added to sonarproperties above. </p>