How to install SQL Server database for SonarQube
SonarQube has an inbuilt database which is meant for evaluation purpose. When we start using SonarQube on the project, we should switch to one of the databases supported by SonarQube.
Here we will discuss how to setup SQL server database for SonarQube. To write our sample code, we will use SQL Server Express Edition 2019.
Learn more about SonarQube:
👉 To read other posts regarding SonarQube Click here
Install SQL Server
Once we are done installing the database, we will also need Microsoft SQL Server Management Studio.
We will download it from Microsoft website and install. You can just search to download it. This is the download link for MSSMS at the time of writing this article.
Once the installation is complete, we will go to SQL Server Configuration Manager.
Go to SQL Server Network Configuration -> Protocols for SQLEXPRESS
Then Select TCP IP. Mark Enabled=Yes
Then go to IP Addresses tab -> IPALL -> TCP Port = 1433
Create New Login
Now go to Start Menu and open Microsoft SQL Server Management Studio.
Select the Server Name. Select default windows authentication.
Open the Object Explorer.
Next open Security folder in the Object Explorer.
Right click on Logins. Select New Login… from the right menu.
On the new login screen create a new user with a Login Name and a password. We will create a user with Login Name as sonar with SQL Server authentication as seen above.
Create New Database
Once, the login is created, Disconnect. Then reconnect the server by clicking on Connect using the new credentials. Right click the Databases folder and select New Database…
In the new screen provide Database Name. We will provide the name as SonarDB. You can provide any name of your choice. We will keep the remaining parameters as default and select the OK button.
The new database name will shown under Databases in the Object Explorer.
Right click SonarDB database to select Database Properties.
Select the correct collation. It should be case sensitive (cs) and accent sensitive (as) as shown below.
Now download the JDBC driver from Microsoft website. This is the download link for JDBC driver at Microsoft site at the time of writing this article.
After downloading JDBC driver, go to sonar.properties file in the conf folder. Uncomment the section with JDBC user and password
We will update the user as sonar and provide the password.
Now under SQL Server, look for JDBC url. Uncomment the url after changing database name to SonarDB. We will also use localhost as the server location for SQL Server as our server is installed locally. In our case this becomes :
Start the SQL Server service. Also start/restart the SonarQube service and open SonarQube in browser. SonarQube should now start use SQL Server database.
In this post, we have downloaded, installed, configured SQL Server to create a database with SQL server authentication. Then we updated sonar.properties file to configure SonarQube to use the SQL Server database we have created.
Let us know if you found this post helpful.