Support Questions

Find answers, ask questions, and share your expertise
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

Application crash due to exception in ODBC Driver

We are using Hortonworks ODBC driver to connect hive from C# application.

Here is a sample code to fire query on Hive.

static void Main(string[] args)

 string connectionString = "DSN=AzureHDP";
 string query = "SELECT * FROM schema_5218.demandquantity";
 int queryTimeout = 100;
  using (var connection = new OdbcConnection(connectionString))
   Console.WriteLine("Opening Hive connection.");
   using (var cmd = connection.CreateCommand())
    cmd.CommandTimeout = queryTimeout;
    cmd.CommandText = query;
    Console.WriteLine("Executing Hive query.");
    Console.WriteLine("Hive query executed successfully.");
 catch (Exception e)
  Console.WriteLine($"Encountered error during Hive query execution. [{e.Message}]");

Issue is that if the network connection drops after the query has been fired on Hive(before query returns) the resulting exception results in application crash.

Reason is that AccessViolcationException is thrown which are not sent to application catch block. So this exception becomes an un-handled exception causing the application to crash.

Is this due to any bug in the ODBC driver? Is there any workaround or fix awaited?

There are certain settings which can be done to catch such exception but those are not recommended by Microsoft. Due this this reason I am not very keep to use these settings. Those settings are [HandleProcessCorruptedStateExceptions] & [SecurityCritical] and legacyCorruptedStateExceptionsPolicy.

Attaching actual application code screenshot. You can that the exception is thrown at the close of the connection using clause and the control does not go to the catch block.

Hortonworks Driver Version:

.Net Version: 4.7

C# version: 7.3



New Contributor

Hello I have to make C# application for my website Custom Essay Writing Company is it a good idea? I need some expert suggestion for C# application.

I have a highly analytical mind and I excel at taking complex ideas and explaining them in accessible language. My writing style is concise and compelling; please take a look at my portfolio and see for yourself.

@Taylor Wilson: I am not sure if I understand what you are looking for. How is your reply related to the question being asked?

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.