Unable to connect Microsoft SQL Database

We are using SonarQube 8.2, and I an unable to connect the Microsoft SQL database we have followed steps that given in the document. But while updating sonar.properties file,i in the file the un-commented lines get comment-out once we restart the web app.

Hi,

Welcome to the community!

What’s the exact error message you’re seeing?

 
Ann

I am using the web app to launch the SonarQube server but I am not able to connect Microsoft database through Azure Portal,When I change the settings in sonar.properties file, but they comment out once we restart the web app.
Is there any other process to connect to database or we are doing it wrong?

# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
#sonar.jdbc.username=sonar
#sonar.jdbc.password={password}

#----- Embedded Database (default)
# H2 embedded database server listening port, defaults to 9092
#sonar.embeddedDatabase.port=9092


#----- Oracle 11g/12c/18c/19c
# The Oracle JDBC driver must be copied into the directory extensions/jdbc-driver/oracle/.
# Only the thin client is supported, and we recommend using the latest Oracle JDBC driver. See
# https://jira.sonarsource.com/browse/SONAR-9758 for more details.
# If you need to set the schema, please refer to http://jira.sonarsource.com/browse/SONAR-5000
#sonar.jdbc.url=jdbc:oracle:thin:@localhost:1521/XE


#----- PostgreSQL 9.3 or greater
# By default the schema named "public" is used. It can be overridden with the parameter "currentSchema".
#sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube?currentSchema=my_schema


#----- Microsoft SQLServer 2014/2016/2017 and SQL Azure
# A database named sonar must exist and its collation must be case-sensitive (CS) and accent-sensitive (AS)
# Use the following connection string if you want to use integrated security with Microsoft Sql Server
# Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Security
# For Integrated Security to work, you have to download the Microsoft SQL JDBC driver package from
# https://www.microsoft.com/en-us/download/details.aspx?id=55539
# and copy sqljdbc_auth.dll to your path. You have to copy the 32 bit or 64 bit version of the dll
# depending upon the architecture of your server machine.
#sonar.jdbc.url={jdbc databse connection string}
    • List item

Hi,

The server settings don’t help me without the exact error message you’re seeing.

 
Ann

it is not showing any error. but the database it not connecting.

Hi,

Okay, your instance is falling back to the embedded database because it hasn’t been given the URL & credentials to connect to an external database. When you uncomment those settings and fill them in correctly, what happens?

If the answer is that it doesn’t start up, then check your logs and post the errors in them if their meaning isn’t obvious to you.

 
Ann

I have entered URL and credentials correctly but still it is falling back to embedded database.

Hi,

To be sure, the server properties you showed above had everything commented-out - i.e. every line started with the comment marker: #. You did remove that marker from the beginning of each relevant line for your DB user name, password, and URL, right?

 
Ann

Yes, I have removed the comment marker(#) only for DB user name, password, and URL, But when I restart my Web App, they again get commented-out .

Hi,

Uhm… I guarantee you that SonarQube and its processes aren’t editing this file. Do you by chance have two copies of the file - the original one with commented lines and the one you’ve updated? Could some external process be swapping one for the other?

 
Ann

I think I might have solution for your problem as I experienced the same thing.

I deployed SonarQube using the following template.

This template deploys SonarQube with an embedded database. I un commented the embedded database and added the details for my Azure SQL server and database in sonar.properties but nothing changed. I believe when deploying SonarQube with this template it does not load this file at startup.

I then made the changes in Azure App Service in Settings - Configuration. I added the following variables.

sonar.jdbc.username =

yoursqladminuser

Name: sonar.jdbc.password =

yoursqladminpassword

Name: sonar.jdbc.url =

jdbc:sqlserver://yoursqlservername.database.windows.net:1433;database=yoursqlserverdatabasename;encrypt=true;

When done save and restart your Web App. Start up will be slightly longer and your credentials for SonarQube will reset to default.

I am having similar issue, in my case after I edit the sonar.properties its not starting the application up .
I updated my application from 7.2 to 7.9. So my 7.9 application is trying to connect to the database that was being used by 7.2 application.
attached are the logs
sonar.log (250.1 KB)