Install sonarqube with MSSQL > can't connect to database

Hi guys

I’m using Sonarqube Version 7.9.1 with no plugins.
Trying to install with mssql database

We’ve installed sonarqube community with the default database (H2) without any issues.
It works on the url : http://localhost:9000

Now we want to go further and we try to install it with an mssql database.
We want to make the install on that version, so we can test the upgrade process on the latest version.

Until now :

We’ve create the SQL database sonar with a dedicated user that is dbowner. The database is on a separate server.
The file sqljdbc_auth.dll is copied in a path location on the sonarqube server

We’ve started with the same configuration and made changes in the connexion strings in sonar.properties.

sonar.jdbc.username=u_sonarqube
sonar.jdbc.password=mypassword
sonar.jdbc.url=jdbc:sqlserver://PC933-2k19;databaseName=sonar;integratedSecurity=true;instanceName=SQLPC933

Now I have some questions :

  • I uninstalled the service, change the logon for the sonarqube service and set the same account as the dedicated sql account. I ran startsonar and startNTservice.bat. Is this ok ?
  • In the actual data folder are all data from the H2 test database, how to wipe all that stuff? Maybe delete the data folder?
  • We works with integrated security (AD Account) so I don’t use the user and password > As I read this > # Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Security
  • In the file sonar.properties I read : # The schema must be created first. Where is the info to create all tables?
  • My database engine is MSSQL 2019. The sonar database is made compatible with 2014

i followed instructions on this link https://docs.sonarqube.org/latest/setup/install-server/ but it does not answer all my questions

So we are now in trouble … Can someone help us ?

Thanks

Hi,

Welcome to the community!

Should be fine.

The data folder contains both your H2 database and your ES indices (by default. You can configure SonarQube to store them elsewhere). The H2 database is fine either way, but it would be a good idea to delete data/es6 to force Elasticsearch to reindex against the new DB

SonarQube will populate the schema with tables &etc. You just need to create it.

It’s not clear to me what your trouble is except that your subject says you can’t connect. Have you checked your server logs?

 
Ann

Thanks ganncamp

Now the sonarqube service starts and also the server (on http://localhost:9000) with the same user as the sqlsever. But it always uses the H2 database. I want to use a new SQL server DB. So I need to completely erase data from H2 DB and start a new one as SQL

I modified the info in the file sonarcube.properties as this :

sonar.jdbc.url=jdbc:sqlserver://PC933-2k19;databaseName=sonar;integratedSecurity=true

We use integrated security and I read this :

Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Security

So I didn’t put a username and password.

Now the service is up and running but still with H2 database and not the SQL …
It seems to not detect the SQL info.

How can I tell sonarqube to use sql instead of H2?

Thanks

By the way, on line 13 in the sonarcube.properties file I read

  • 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.jdbc.password=

And later I read on line 40

  • Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Security

This is a bit confusing. the sonar.jdbc.url needs credentials to connect to the server … So I presume it will use the same user credentials as the one that runs the NTservice. Is this correct?

Hi,

If SonarQube sees

  1. configuration for a database it can reach, it will connect and start up.
  2. configuration for a database it cannot reach, it will not start up. You will find the cause in web.log
  3. no database configuration it will fall

It sounds to me like you’re in situation 3. Now it’s time to figure out why SonarQube isn’t recognizing your DB configuration. You did remove the # from the front of the JDBC URL line, didn’t you?

 
Ann

Hi Ann

Thanks for your answers.

Sure, I remove the # from the front of the JDBC URL line.

I try several things but I always restar t from a running snapshot with H2 database.

  1. How can I remove the whole database H2. I delete the whole DATA folder. Is this the right way to proceed?

  2. How can I start with a clean install.

  3. In web.log After erasing the data folder
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host PC933-2K19/SQLPC33, port 1433 has failed
    Question : must you specify the instance of SQL

  4. When I run sonarstart with default DB h2, it’s running until I see “sonarqube is UP” and it continuous during hours struggeling over plugins.

  5. May I run sonarstart as much as I want?

Any idea?

Hi Ann

It’s running with MSSQL !!! :slight_smile:

It was logging and password that was not filled in …
This is not clear in the properties file comments as I read that you don’t need them if you use integrated security.

Thanks

1 Like