0

I have created a c# windows service and want to Connect to Databricks Delta table from c# code using JDBC/ODBC connection with below host for updating/inserting in couple of databricks delta tables.

Trying using SIMBA ODBC connection but got the error as Data source name not found and no default driver specified'

public static void Main(string[] args)
    {
        
        // Build connection string
        OdbcConnectionStringBuilder odbcConnectionStringBuilder = new OdbcConnectionStringBuilder
        {
            Driver = "Simba Spark ODBC Driver", //Simba Spark ODBC Driver
           Dsn = "Simba Spark"
        };
        odbcConnectionStringBuilder.Add("Host", "sas-tes-dev.cloud.databricks.com");
        odbcConnectionStringBuilder.Add("Port", "443");
        odbcConnectionStringBuilder.Add("SSL", "1");
        odbcConnectionStringBuilder.Add("ThriftTransport", "2");
        odbcConnectionStringBuilder.Add("AuthMech", "3");
        odbcConnectionStringBuilder.Add("UID", "token");
        odbcConnectionStringBuilder.Add("PWD", "dapisds62728299255b4");
        odbcConnectionStringBuilder.Add("HTTPPath", "sql/protocolv1/o/6709534942857832/0208-221830-graph177");


        using (OdbcConnection connection = new OdbcConnection(odbcConnectionStringBuilder.ConnectionString))
        {
            string sqlQuery = "select * from mpre_sm.innsme";
            OdbcCommand command = new OdbcCommand(sqlQuery, connection);
            connection.Open();
            OdbcDataReader reader = command.ExecuteReader();

            for (int i = 0; i < reader.FieldCount; i++)
            {
                Console.Write(reader.GetName(i) + "\t");
            }

            Console.Write("\n");

            reader.Close();
            command.Dispose();
        }
    }

Please help to provide C# code snipped and suggestions to achieve this.

enter image description here

V J
  • 77
  • 12
  • What have you tried? Does this help? https://learn.microsoft.com/en-us/answers/questions/340847/can-a-net-c-application-connect-and-query-from-an.html – Nick.Mc Oct 19 '21 at 07:07
  • I am using apache databricks , I haven't tried any c# connectivity yet and want to stablish the connection to read /write the data, not sure from where to start writing a code for creating connection with above configuration I have shared. – V J Oct 19 '21 at 10:59
  • Why don't you try this example and confirm that you can at least connect. https://stackoverflow.com/questions/66750474/simba-odbc-connection-to-delta-table-read-data-from-delta-format-tables-using – Nick.Mc Oct 19 '21 at 11:16
  • Post the code that you already tried – Alex Ott Oct 19 '21 at 11:26
  • @Nick.McDermaid I just tried using simba odbc connection , getting this error :- ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified' – V J Oct 19 '21 at 12:04
  • @AlexOtt please check the code snippet I have updated in original question , i have installed SIMBA oledb driver and connecting with that – V J Oct 19 '21 at 12:08
  • Dsn that you are trying to use has to be configured in ODBC drivers system utility, 64 bit if the machine is 64 bit and 32 bit otherwise on a windows machine. – brajesh jaishwal Mar 17 '22 at 09:24

0 Answers0