MSSQL JDBC driver won't connect to mirror failoverPartner on first connect

孤街浪徒 提交于 2019-11-30 07:15:35
Chloe

I found the answer! You have to specify the instance name as part of the host name! Example:

jdbc:sqlserver://DEVSQLB\SQLB;databaseName=db_space;portNumber=99999;failoverPartner=BACKUPSQLA\SQLA

where \SQLA is the instance name! I'm not exactly sure what an instance is, but I've seen it referred to many times in SQL Server. To find this secret information out, I (my company) had to request support directly from Microsoft.

Oh, forgot:

  • You can fix this issue by using the format "server\instance_name" and make sure that the browser service is running and in automatic mode.

The Sql Server JDBC driver documentation here has the following (confusing) disclaimer:

Note The driver does not support specifying the server instance port number for the failover partner instance as part of the failoverPartner property in the connection string. However, specifying the serverName, instanceName and portNumber properties of the principal server instance and failoverPartner property of the failover partner instance in the same connection string is supported.

From this I would suggest adding: serverName=PRINCIPALDB;instanceName=MyInstance properties and see if that works.


You mention that the failover is active. Note that for some Sql Server mirror configurations a failover is not automatic. You may want to verify that you can connect to your MIRRORDB using jdbc:

jdbc:sqlserver://MIRRORDB;databaseName=app_space;port=9999;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!