Connect to Hadoop via Hive ODBC from C#

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

Answers


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

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


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;
        }

Need Your Help

Unauthorized access in Filepicker in Windows Store App

c# windows microsoft-metro

hello guys im having troubles regarding this code:

Unable to load com.mysql.jdbc.Driver

mysql ant testng

when I run ant for a Testng application, I am unable to load com.mysql.jdbc.Driver.