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

后端 未结 2 1208
甜味超标
甜味超标 2020-12-30 11:20

I\'m using C3P0 and the MS SQL JDBC 4 driver to automatically failover to a new database mirror when the database goes away. If it first connects to the principal DB, then t

相关标签:
2条回答
  • 2020-12-30 11:50

    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.
    0 讨论(0)
  • 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;
    
    0 讨论(0)
提交回复
热议问题