Question

How can I connect to Hadoop via Hive ODBC from C# ? Any code sample would be great too. I am not using Azure HDInsight.

No correct solution

OTHER TIPS

Install the ODBC driver for you hive. And configure it. Eg in the example I have configured the dsn name as horton. Here is the code:

 static DataTable  GetDataFromHive()
        {
            OdbcConnection DbConnection = new OdbcConnection("DSN=horton");
            try
            {
                DbConnection.Open();
            }
            catch (OdbcException ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
            OdbcCommand cmd = DbConnection.CreateCommand();
            cmd.CommandText = "SELECT * FROM sample_08 LIMIT 100;";
            DbDataReader dr = cmd.ExecuteReader();
            var dataTable = new DataTable();
            dataTable.Load(dr);
            DbConnection.Close();
            return dataTable;
        }

I tried to answer my own question by posting an article in codeproject.

How to communicate to Hadoop via Hive using .NET/C#

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top