Connecting to MS SQL Database Fails Due to 'Unable to get information from SQL Server' Error
Symptoms
Confluence is unable to start, and Internal Server 500 errors are shown in the browser.
The following error appears in the log file:
2014-07-24 09:31:51,370 WARN [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] [mchange.v2.resourcepool.BasicResourcePool] run com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1f53ceb4 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
java.sql.SQLException: Unable to get information from SQL Server: localhost.
Cause
When using a named instance, jTDS (the driver used by Java applications to communicate with SQL Server) sends a UDP packet to the server over port 1434 to the SQL Browser Service to find the port that it can use to connect to the instance. It appears that this UDP request is not being responded to in time (if at all). This is usually because the SQL Browser service is not running. This is documented in Sourceforge's jTDS documentation:
On SQL Server 2005 [and up] the SQL Browser service must be running on the server host as the instance name lookup port UDP 1434 is hosted by this service on SQL Server 2005 [and up] rather than the SQL Server itself. The default install does not configure the SQL Browser service to start automatically so you must do it manually.
Resolution
- Ensure that the SQL Browser service is running on your database server.
- Ensure that JDBC URL in
confluence.cfg.xml
is configured properly.
Alternatively, you can connect directly to the port used by the named instance. However, from Microsoft's documentation:
By default, when enabled, both named instances and SQL Server Express are configured to use dynamic ports, that is, an available port is assigned when SQL Server starts. If you want, a specific port can be assigned to an instance of SQL Server. When connecting, clients can specify a specific port; but if the port is dynamically assigned, the port number can change anytime SQL Server is restarted, so the correct port number is unknown to the client.
Thus, enabling the SQL Browser service is the more desirable option.