Java IllegalStateException: Fail to connect to database - when trying to start the service

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

I’ve followed the instructions in the documentation for wiring the sonarqube service to a SQL Server database.

  1. created the empty schema database, with CS collation,
  2. copied the sqljdbc_auth.dll to the bin folder in the installation directory
    • the instructions only say to copy it “anywhere in my path” so initially I put it into windows/system32 and when that didn’t work I put it into the bin folder
  3. modified the sonar.properties file as follows:
#----- 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:sqlserver://localhost;databaseName=sonar;integratedSecurity=true

sonar.jdbc.url=jdbc:sqlserver://sqlserver2/sql2016;databaseName=SONAR;integratedSecurity=true
  1. tried to start the service - got the following web log entry
2019.08.29 16:33:25 INFO  web[][o.sonar.db.Database] Create JDBC data source for jdbc:sqlserver://sqlserver2/sql2016;databaseName=SONAR;integratedSecurity=true
2019.08.29 16:33:40 ERROR web[][o.s.s.p.Platform] Web server startup failed
java.lang.IllegalStateException: Fail to connect to database
	at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:90)
	at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:40)
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
	at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
	at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
	at org.picocontainer.behaviors.Stored.start(Stored.java:110)
	at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
	at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
	at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)
	at org.sonar.server.platform.platformlevel.PlatformLevel1.start(PlatformLevel1.java:160)
	at org.sonar.server.platform.Platform.start(Platform.java:211)
	at org.sonar.server.platform.Platform.startLevel1Container(Platform.java:170)
	at org.sonar.server.platform.Platform.init(Platform.java:86)
	at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4817)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5283)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1423)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1413)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').
	at org.sonar.db.DefaultDatabase.checkConnection(DefaultDatabase.java:134)
	at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:87)
	... 24 common frames omitted
Caused by: java.sql.SQLException: Cannot create PoolableConnectionFactory (The TCP/IP connection to the host sqlserver2/sql2016, port 1433 has failed. Error: "sqlserver2/sql2016. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".)
	at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2385)
	at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2110)
	at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1563)
	at org.sonar.db.profiling.NullConnectionInterceptor.getConnection(NullConnectionInterceptor.java:31)
	at org.sonar.db.profiling.ProfiledDataSource.getConnection(ProfiledDataSource.java:317)
	at org.sonar.db.DefaultDatabase.checkConnection(DefaultDatabase.java:131)
	... 25 common frames omitted
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host sqlserver2/sql2016, port 1433 has failed. Error: "sqlserver2/sql2016. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)
	at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285)
	at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2431)
	at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:656)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2440)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2103)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1950)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1162)
	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:735)
	at org.apache.commons.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:53)
	at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:291)
	at org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2395)
	at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2381)
	... 30 common frames omitted
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][[timer]]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/java.lang.Thread.sleep(Native Method)
 app//org.elasticsearch.threadpool.ThreadPool$CachedTimeThread.run(ThreadPool.java:574)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][scheduler][T#1]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/jdk.internal.misc.Unsafe.park(Native Method)
 java.base@11.0.3/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
 java.base@11.0.3/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
 java.base@11.0.3/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
 java.base@11.0.3/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][transport_worker][T#1]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:339)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:167)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
 app//io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 app//io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:765)
 app//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:413)
 app//io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][generic][T#1]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/jdk.internal.misc.Unsafe.park(Native Method)
 java.base@11.0.3/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.awaitMatch(LinkedTransferQueue.java:743)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.xfer(LinkedTransferQueue.java:684)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.take(LinkedTransferQueue.java:1366)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][transport_worker][T#2]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:339)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:167)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
 app//io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 app//io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:765)
 app//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:413)
 app//io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][transport_worker][T#3]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:339)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:167)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
 app//io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 app//io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:765)
 app//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:413)
 app//io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][transport_worker][T#4]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:339)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:167)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
 app//io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 app//io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:765)
 app//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:413)
 app//io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][transport_worker][T#5]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:339)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:167)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
 app//io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 app//io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:765)
 app//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:413)
 app//io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][transport_worker][T#6]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:339)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:167)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
 app//io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 app//io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:765)
 app//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:413)
 app//io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][transport_worker][T#7]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:339)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:167)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
 app//io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 app//io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:765)
 app//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:413)
 app//io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][transport_worker][T#8]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:339)
 java.base@11.0.3/sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:167)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:124)
 java.base@11.0.3/sun.nio.ch.SelectorImpl.select(SelectorImpl.java:136)
 app//io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 app//io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:765)
 app//io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:413)
 app//io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][generic][T#2]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/jdk.internal.misc.Unsafe.park(Native Method)
 java.base@11.0.3/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.awaitMatch(LinkedTransferQueue.java:743)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.xfer(LinkedTransferQueue.java:684)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.take(LinkedTransferQueue.java:1366)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][generic][T#3]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/jdk.internal.misc.Unsafe.park(Native Method)
 java.base@11.0.3/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.awaitMatch(LinkedTransferQueue.java:743)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.xfer(LinkedTransferQueue.java:684)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.take(LinkedTransferQueue.java:1366)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 WARN  web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [elasticsearch[_client_][generic][T#4]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.3/jdk.internal.misc.Unsafe.park(Native Method)
 java.base@11.0.3/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.awaitMatch(LinkedTransferQueue.java:743)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.xfer(LinkedTransferQueue.java:684)
 java.base@11.0.3/java.util.concurrent.LinkedTransferQueue.take(LinkedTransferQueue.java:1366)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
 java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
2019.08.29 16:33:40 INFO  web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2019.08.29 16:33:40 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process

Hi,

Welcome to the community!

You’ve put the crux of the error in the title of your thread. So… what’s the question?

BTW, the ‘Caused by’ lines give slightly more detail (emphasis added):

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host sqlserver2/sql2016, port 1433 has failed. Error: “sqlserver2/sql2016. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.”.

Sounds like your SonarQube instance can’t see a DB at that URL & port.

 
Ann

Hi Ann,

Thanks for the reply. As you said it seems that the SonarQube instance can’t see a DB at that URL and port. I suppose the question is: why not. That is the correct URL however I cannot find a way to change the TCP port that sonarqube is
attempting to use (1433) to the TCP port that we have configured on the SQL Server instance (2003).

Please tell me how to change the TCP port on sonarqube.

Thanks,

Steve Satterfield

(770) 815-8061 cell/text

Hi Steve,

That’s a bit beyond my scope, but Google points me to MS docs: https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-2017

 
HTH,
Ann

Hi Ann,

Problem solved! Thanks so much for the document. The fix turned out to be a combination of two things: 1) specify the port after the SQL Server host, and 2) ONLY name the SQL Server host NOT the specific instance of SQL Server on that host.

We changed this:

Sonar.jdbc.url=jdbc:sqlserver://sqlserver2\sql2016;databaseName=SONAR;integratedSecurity=true

To this:

Sonar.jdbc.url=jdbc:sqlserver://sqlserver2:2003;databaseName=SONAR;integratedSecurity=true

Only specifying the host name and not the SQL Server instance name was the part that had me stumped the longest.

Thanks again,

Steve Satterfield

(770) 815-8061 cell/text

Hi Ann,

Now that we have our database connectivity issue resolved we have another question with regard to sonar scanner and the sonarqube service.

I have set up a service endpoint for the sonarqube service, which is running on a VM that has the necessary version of Java (11) to support Sonarqube. These Azure Devops marketplace tasks below are attempting however, to the best of my
knowledge, to run the sonar scanner on the .net code on the build server and then send in the results via the service endpoint for analysis by sonarqube.

Prepare for Sonar Scan and Analysis

Hi Steve,

Please start a new thread for that.

 
:slightly_smiling_face:
Ann

Thanks. Will do.

Steve

2 posts were split to a new topic: Fail to connect to database