Unable to Connect to MS SQL Server Due to DB server closed connection

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Symptoms

  • The JIRA application fails to start when running the startup checks.
  • The JIRA application fails to create an XML backup successfully.

The following appears in the atlassian-jira.log:

2012-07-18 17:54:23,978 main ERROR      [jira.appconsistency.db.DatabaseConsistencyCheck] There was a SQL exception checking for database driver correctness. Skipping.
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (I/O Error: DB server closed connection.)
	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
	at org.ofbiz.core.entity.transaction.JNDIFactory.getJndiConnection(JNDIFactory.java:207)
	at org.ofbiz.core.entity.transaction.JNDIFactory.getConnection(JNDIFactory.java:138)
	at org.ofbiz.core.entity.TransactionFactory.getConnection(TransactionFactory.java:101)
	at org.ofbiz.core.entity.ConnectionFactory.getConnection(ConnectionFactory.java:59)
    ...
Caused by: java.sql.SQLException: I/O Error: DB server closed connection.
	at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2311)
	at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:603)
	at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:357)
	at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
	at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
	at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
	at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
	... 40 more
Caused by: java.io.IOException: DB server closed connection.
	at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:844)
	at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:723)
	at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:466)
	at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:103)
	at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2206)
	... 48 more

Or

2013-09-10 07:34:51,624 QuartzScheduler_Worker-2 ERROR ServiceRunner    Backup Service [service.services.export.ExportService] An exception while running the export service "Backup Service": Error exporting data: org.ofbiz.core.entity.GenericTransactionException: Error occurred while rolling back transaction. (Connection net.sourceforge.jtds.jdbc.ConnectionJDBC3@11931fc4 is closed.)
com.atlassian.core.AtlassianCoreException: Error exporting data: org.ofbiz.core.entity.GenericTransactionException: Error occurred while rolling back transaction. (Connection net.sourceforge.jtds.jdbc.ConnectionJDBC3@11931fc4 is closed.)
	at com.atlassian.jira.service.services.export.ExportService.performBackup(ExportService.java:149)
	at com.atlassian.jira.service.services.export.ExportService.run(ExportService.java:131)
	at com.atlassian.jira.service.JiraServiceContainerImpl.run(JiraServiceContainerImpl.java:61)
	at com.atlassian.jira.service.ServiceRunner.execute(ServiceRunner.java:48)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:195)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)

Cause

This is most likely caused by either of the following:

  1. The SQL Server uses an SSL connection and a valid client certificate is required to communicate with the SQL Server. This can be verified by checking the SQL Server logs in Event Viewer for the following error:

    Encryption is required to connect to this server but the client library does not support encryption.
  2. The SQL server is running on a port that is not the default 1433. For example, binding to SQL server on 2431 can cause this problem.

Resolution

Using SSL:

  1. First verify that the JIRA application server can both ping and telnet to the database server.
  2. Disable the "Force Encryption On" setting on the MS SQL Server.

  3. Restart the JIRA application and monitor the atlassian-jira.log to see if the connection is successful.

OR

Install the certificate from the SQL Server into the keystore that the JIRA application uses as per our Connecting to SSL services.

Using a non-standard port:

Review this MSDN blog on tips for making application connectivity work.

Last modified on Jan 24, 2025

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.