0
votes

MySQL version: 5.6.25 (64-bit Linux). Ant version: 1.9.5. Sonarqube version: 5.1.1. I'm getting permission issues when I run my ant script. Things like:

org.sonar.runner.impl.RunnerException: Unable to execute Sonar ... .. caused by java.lang.IllegalStateException: Fail to connect to database .... ... caused by org.apache.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (access denied for user 'sonarqube'@'localhost' (using password: YES))

After spending yesterday afternoon of googling and trying to log into MySQL as root and calling GRANT ALL on etc etc for my sonarqube user and things like that I'm completely at a loss what to try next. I came across this post: http://sonarqube.15.x6.nabble.com/com-mysql-jdbc-Driver-is-not-found-td5012081.html, specifically this bit:

"Sonar uses its build-in driver which lies in /home/jenkins/sonar-3.5.1/extensions/jdbc-driver/mysql/ The file mysql-connector-java-5.1.18.jar exists, is readable and contains the Driver.class file."

I do not have a connector jar file in this location (in fact the only folder I have in the extensions directory is 'oracle'). Should I have one? In terms of the sonarqube documentation I don't have to configure MySQL to use anything extra drivers from elsewhere.

Many thanks in advance. I could paste in parts of my Ant script if required, but this does look more like a database permissions issue. Cheers, Tom

2
edit: I've just noticed under the "Failed to connect to database" in the exception stack trace this:"at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:77)". Could this mean it's still trying to use some parts of the default H2 DB? I've removed all references of this from my sonar.properties file so now I'm even more confused :)mutexe
you can try after export like export "ANT_LIB=/path-till-ant/apache-ant-1.9.4/lib"Zafar Malik
Thanks for the reply. I have already set up an environmental variable for ant. Thank you though :)mutexe

2 Answers

0
votes

Configure your MySQL, by default only localhost connection is enable.

GRANT ALL PRIVILEGES ON *.* TO 'user'@'YOUR_IP_ADDRESS'
0
votes

First Thing first.

You are triggering SonarQube using ANT. For further details you can have a look here.

So, As per the Error log, it seems that its permission issue for your project. Sonar is unable to connect to your Database.

Suppose your database is Sonar

username = sonar
password = sonar

In this case you have to give privileges to your database for connecting. For providing privileges you have to run following commands.

GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'DOMAIN-NAME' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'127.0.0.1' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'CURRENT-IP-ADDRESS' IDENTIFIED BY 'sonar';

Please check for more details here.