I just downloaded Sonar 3.2 and have configured the sonar.properties files to connect to my local MySql database. I have the following setting enabled:
sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
I am able to start the server without any errors and am able to log into the Sonar interface however when I run 'mvn sonar:sonar' on my maven project I get the following error:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project vrservices: Can not execute Sonar: Fail to connect to database: Cannot load JDBC driver class 'org.h2.Driver' -> [Help 1]
I have read a few forums that saying to put the following code in the settings.xml file however this still didn't fix the issue.
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- EXAMPLE FOR MYSQL -->
<sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url>
<sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
<sonar.jdbc.username>root</sonar.jdbc.username>
<sonar.jdbc.password></sonar.jdbc.password>
</properties>
</profile>
I was wondering if anyone has come across this issue as well and if so how did you fix it?
Thanks in advance!
If you don't configure the Maven Sonar plugin, it will attempt to connect to the default location for the embedded database that ships with Sonar. Starting with version 3.2 the default embedded database is H2 (replacing derby).
The forum recommendations are correct, I suspect that your Maven instance is not loading the correct settings file. Try running Maven as follows:
mvn -s /path/to/settings/file/setting.xml sonar:sonar
see that the attribute 'sonar.jdbc.url' in settings.xml and sonar.properties file are the same. secondly create a schema by name 'sonar' before you try to run the sonar server. good luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With