HOWTO ODBC .NET Framework connection with failover support
In his post “HOWTO ODBC .Net framework connection” (http://scn.sap.com/docs/DOC-33628), Keven Lachanced showed us how to connect to HANA using the .NET Framework and ODBC.
Keven’s post is very helpful and I would like to add to it by showing how you can add scale out failover support to the ODBC connection.
Within the SAP HANA Administration Guide under section Configuring Clients for Failover we are instructed to add a list of potential master servers, separated by a semicolon, to the connection string:
I found that this does not work when using ODBC in the .NET Framework. It seems that the first host in the list is parsed and only that host is used when making connections.
For example, when attempting to add multiple hosts to Keven’s example:
const string _strServerName = “hanaServer1:30015;hanaServer2:30015;hanaServer3:30015”;
In this example, only hanaServer1:30015 will be considered for a connection.
I found that by adding a comma, not a semicolon, between the host entries, failover support was successfully added to the .NET ODBC connection:
const string _strServerName = “hanaServer1:30015,hanaServer2:30015,hanaServer3:30015”;
In this example, if the connection to hanaServer1:30015 is not successful, then an attempt is made to hanaServer2:30015. If that connection is not successful then an attempt is made to hanaServer3:30015. Only when a connect is not possible to any of the servers in the list that an exception is thrown.