SQL Server connection with...domain?

Hi, I’m using SonarQube 10.7.0.96327 on Windows with Java version 17 and SQL Server version 16.0.1115.

I’m trying to start SonarQube for the first time and the database connection always fails. When I connect to my SQL Server with SSMS, the server name is shown as ABC123\DEVELOPMENT. I suspect that my connection fails because I’m writing the connection string incorrectly. My sonar.properties connection string looks like this:

sonar.jdbc.url=jdbc:sqlserver://ABC123\DEVELOPMENT;databaseName=sonar;integratedSecurity=true;

A couple of lines from my web.log show this:

2024.11.14 15:47:24 WARN  web[][o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@659e0bfd-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database
2024.11.14 15:47:24 ERROR web[][o.s.s.p.w.PlatformServletContextListener] Web server startup failed

I’ve also tried ABC123 and DEVELOPMENT and ABC123/DEVELOPMENT. I’ve even tried using localhost as the sqlserver. Now I’m wondering if I need to add another attribute to the connection string, but I haven’t been able to figure it out.

Hi,

Welcome to the community!

I suspect there’s more to that error than you’ve shared. Can you copy/paste - at minimum, the full stacktrace if not the full log?

 
Thx,
Ann

I believe this is the stack trace, and the sonar.log file is attached.

Starting SonarQube...
2024.11.15 10:30:42 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory C:\Data\Apps\sonarqube-10.7.0.96327\temp
2024.11.15 10:30:42 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:53450]
2024.11.15 10:30:42 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [C:\Data\Apps\sonarqube-10.7.0.96327\elasticsearch]: c:\program files\java\jdk-17\bin\java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=./bin/elasticsearch -Dcli.libs=lib/tools/server-cli -Des.path.home=C:\Data\Apps\sonarqube-10.7.0.96327\elasticsearch -Des.path.conf=C:\Data\Apps\sonarqube-10.7.0.96327\temp\conf\es -Des.distribution.type=tar -cp C:\Data\Apps\sonarqube-10.7.0.96327\elasticsearch\lib\*;C:\Data\Apps\sonarqube-10.7.0.96327\elasticsearch\lib\cli-launcher\* org.elasticsearch.launcher.CliToolLauncher
2024.11.15 10:30:42 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2024.11.15 10:30:49 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2024.11.15 10:30:49 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[WEB_SERVER] from [C:\Data\Apps\sonarqube-10.7.0.96327]: c:\program files\java\jdk-17\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\Data\Apps\sonarqube-10.7.0.96327\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-10.7.0.96327.jar;C:\Data\Apps\sonarqube-10.7.0.96327\lib\jdbc\mssql\mssql-jdbc-12.6.3.jre11.jar org.sonar.server.app.WebServer C:\Data\Apps\sonarqube-10.7.0.96327\temp\sq-process13253612907814817682properties
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.sonar.process.PluginSecurityManager (file:/C:/Data/Apps/sonarqube-10.7.0.96327/lib/sonar-application-10.7.0.96327.jar)
WARNING: Please consider reporting this to the maintainers of org.sonar.process.PluginSecurityManager
WARNING: System::setSecurityManager will be removed in a future release
2024.11.15 10:31:00 INFO  app[][o.s.a.SchedulerImpl] Process[Web Server] is stopped
2024.11.15 10:31:00 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2024.11.15 10:31:00 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped

sonar.log (7.0 KB)

Hi,

You’ve provided the sonar.log, which doesn’t contain a stacktrace. Your initial snippet was from web.log. So that’s the log we’re interested in here.

 
Ann

web.log (8.6 KB)

Web.log is sanitized and attached.

Hi,

Here you go:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host ABC123, named instance DEVELOPMENT failed. Error: "java.net.SocketTimeoutException: Receive timed out". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.

 
HTH,
Ann

I figured out the problem, and it ended up being a few issues. The main issue was that the connection string was not correct for my SonarQube database. To fix that, I used the ms-sqlserver-jdbc tester to connect to another database to get the base connection attributes correct, then modified that to connect to the SonarQube database.

1 Like