none
JDBC Connection String error in SQL 2008 Mirioring failover

    คำถาม

  • Hello All,

    Info:

    I am using SQL server 2008 R2 on both serves are on same version and JDBC version we are using is 3.0 and both the servers are on default instance

    I am having an Issue here regarding the JDBC connection string in SQL Server 2008 R2 mirrioring. below is the URL I am using

    jdbc:sqlserver://Server-A:1433;databaseName=Db_Name;failoverPartner=Server-B

    Here are the cases:

    Case-1: If the Server-A is working fine and server-B is in mirror stage, then below URL is working

    jdbc:sqlserver://Server-A:1433;databaseName=Db_Name;failoverPartner=Server-B

    case-2: If the Server-A is not working and server-B is in active stage, then below URL is NOT working

    jdbc:sqlserver://Server-A:1433;databaseName=Db_Name;failoverPartner=Server-B

    if I modify the above URL to

    jdbc:sqlserver://Server-B:1433;databaseName=Db_Name;failoverPartner=Server-A then it's working fine.

    The problem is to modify the URL I need to take the application down and it will take 10-15 minutes to restart the whole application back to normal which I cant afford the amount of time.

    Below is the error message I am getting after I do the database failover:

    com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host Server-A, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
          at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
          at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1033)
          at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
          at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
          at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
          at java.sql.DriverManager.getConnection(Unknown Source)
          at java.sql.DriverManager.getConnection(Unknown Source)
          at TestSQLServer.<init>(TestSQLServer.java:20)
          at TestSQLServer.main(TestSQLServer.java:55)

    I tried the option of adding the default instance name after the server name,and I also checked if the TCP/IP ports are open in both servers and are enabled.

    Thanks u all for the valuable advices

    7 กรกฎาคม 2554 14:35

ตอบทั้งหมด