问题
I am working on a legacy project that uses jTDS to connect to SQL server. The client wants us to support SQL Server 2012 AlwaysOn. one key requirement is the ability of our application to automatically reconnect to secondary server in event of failover.
unfortunately, jTDS 3.0 does not support AlwaysOn. I have 2 options
- use MS JDBC (http://www.microsoft.com/en-us/download/confirmation.aspx?id=11774)
- Write a wrapper that returns the connection string after checking the status of the active node
option 1 is serious engineering(heavy testing) effort. Has anyone tried option 2 or something else to use jTDS to connect to SQL 2012 avilablity group listener? if yes please provide some guidance
回答1:
After tweaking my DAL to handle specific SQL Errors, I was able to retry all the transactions whenever there was a Availability group fail-over.
I am handling the following SQL Errors
Severity 16 DB error codes (10054, 233, 232, 2812, 64, 3906) Severity 14 Db error codes (983, 922, 945)
来源:https://stackoverflow.com/questions/16651383/using-jtds-to-connect-to-sql-server-2012-availability-group-listener