<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can I connect to a MS SQL server table in Databricks account? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30019#M21700</link>
    <description>&lt;P&gt;Hi Vida,&lt;/P&gt;&lt;P&gt;Thank you for your response and for your suggestion to go to this particular notebook. I got the connection now!&lt;/P&gt;&lt;P&gt;For future reference, these where the obstacles for me&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;"You just need to use the right JDBC driver." --&amp;gt; Where could I find 'the right JDBC driver'? I found sqljdbc4.jar somewhere, uploaded it in 'create library' before starting the cluster (or restart cluster).&lt;/LI&gt;&lt;LI&gt; Azure has a JDBC connection string that you can copy, there you can clearly find the parameters you need. I used this complete connection string in the "url"&lt;/LI&gt;&lt;LI&gt;don't forget to whitelist the IP address in Azure&lt;/LI&gt;&lt;LI&gt;I wasn't sure what to use for the 'driver'. This worked for me: "driver" -&amp;gt; "com.microsoft.sqlserver.jdbc.SQLServerDriver" &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;val resultsDF = sqlContext.load("jdbc", Map( "driver" -&amp;gt; "com.microsoft.sqlserver.jdbc.SQLServerDriver",&lt;/P&gt;&lt;P&gt; "url" -&amp;gt; s"jdbc:sqlserver://xxxxx.database.windows.net:1433;database=yyyydb01;user=someuser@xxxxx;password=secret;encrypt=true; trustServerCertificate=false;hostNameInCertificate=*.&lt;A href="http://database.windows.net" alt="http://database.windows.net" target="_blank"&gt;database.windows.net&lt;/A&gt;;loginTimeout=30;", "dbtable" -&amp;gt; s"$t_table"))&lt;/P&gt;&lt;P&gt;And in a SQL Notebook: CREATE TEMPORARY TABLE jdbcTable USING org.apache.spark.sql.jdbc OPTIONS ( url "jdbc:sqlserver://&lt;A href="http://xxxxx.databse.windows.net" alt="http://xxxxx.databse.windows.net" target="_blank"&gt;xxxxx.databse.windows.net&lt;/A&gt;;DabaseName=yyyydb01;user=someuser;password=secret", dbtable "SalesLT.Product")&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
    <pubDate>Fri, 06 Nov 2015 22:48:44 GMT</pubDate>
    <dc:creator>Tamara</dc:creator>
    <dc:date>2015-11-06T22:48:44Z</dc:date>
    <item>
      <title>Can I connect to a MS SQL server table in Databricks account?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30017#M21698</link>
      <description>&lt;P&gt;I'd like to access a table on a MS SQL Server (Microsoft). Is it possible from Databricks?&lt;/P&gt; 
&lt;P&gt;To my understanding, the syntax is something like this (in a SQL Notebook): &lt;/P&gt; 
&lt;P&gt;CREATE TEMPORARY TABLE jdbcTable &lt;/P&gt;
&lt;P&gt;USING org.apache.spark.sql.jdbc &lt;/P&gt;
&lt;P&gt;OPTIONS ( url "jdbc:sqlserver://aaaa.database.windows.net;DatabaseName=bbbb;user=xxx;password=yyy", &lt;/P&gt; dbtable "SalesLT.Product" )
&lt;P&gt;&lt;/P&gt; 
&lt;P&gt;The following error occurs: Error in SQL statement: SQLException: No suitable driver found for jdbc:sqlserver&lt;/P&gt;
&lt;P&gt;Some research brought me here: &lt;A href="https://spark.apache.org/docs/1.3.0/sql-programming-guide.html#jdbc-to-other-databases" target="test_blank"&gt;https://spark.apache.org/docs/1.3.0/sql-programming-guide.html#jdbc-to-other-databases&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Based on this sentence: "To get started you will need to include the JDBC driver for you particular database on the spark classpath." I uploaded the sqljdbc4.jar in the library and attached to the cluster, but unfortunately the error still occurs.&lt;/P&gt;
&lt;P&gt;I'd very much like to do this in either R or SQL, unfortunately I don't know Java or Scala that well, Python is so-so.&lt;/P&gt;
&lt;P&gt;I'm relatively new to Spark - any help is much appreciated!&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 12:01:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30017#M21698</guid>
      <dc:creator>Tamara</dc:creator>
      <dc:date>2015-11-03T12:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can I connect to a MS SQL server table in Databricks account?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30018#M21699</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi Tamara,&lt;/P&gt;
&lt;P&gt;Please go to the Databricks Guide &amp;gt;&amp;gt; Accessing Data &amp;gt;&amp;gt; Databases &amp;amp; Datasources &amp;gt;&amp;gt; JDBC for SQL databases notebook.&lt;/P&gt;
&lt;P&gt;Did you try that? Which step did you get stuck? There is code in that notebook to make sure that you have the correct driver for your SQL server type installed by using a regular java JDBC connection. Can you get that to work first? It's best to troubleshoot that before trying to get Spark to connect to your database.&lt;/P&gt;
&lt;P&gt;-Vida&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 17:51:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30018#M21699</guid>
      <dc:creator>vida</dc:creator>
      <dc:date>2015-11-06T17:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Can I connect to a MS SQL server table in Databricks account?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30019#M21700</link>
      <description>&lt;P&gt;Hi Vida,&lt;/P&gt;&lt;P&gt;Thank you for your response and for your suggestion to go to this particular notebook. I got the connection now!&lt;/P&gt;&lt;P&gt;For future reference, these where the obstacles for me&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;"You just need to use the right JDBC driver." --&amp;gt; Where could I find 'the right JDBC driver'? I found sqljdbc4.jar somewhere, uploaded it in 'create library' before starting the cluster (or restart cluster).&lt;/LI&gt;&lt;LI&gt; Azure has a JDBC connection string that you can copy, there you can clearly find the parameters you need. I used this complete connection string in the "url"&lt;/LI&gt;&lt;LI&gt;don't forget to whitelist the IP address in Azure&lt;/LI&gt;&lt;LI&gt;I wasn't sure what to use for the 'driver'. This worked for me: "driver" -&amp;gt; "com.microsoft.sqlserver.jdbc.SQLServerDriver" &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;val resultsDF = sqlContext.load("jdbc", Map( "driver" -&amp;gt; "com.microsoft.sqlserver.jdbc.SQLServerDriver",&lt;/P&gt;&lt;P&gt; "url" -&amp;gt; s"jdbc:sqlserver://xxxxx.database.windows.net:1433;database=yyyydb01;user=someuser@xxxxx;password=secret;encrypt=true; trustServerCertificate=false;hostNameInCertificate=*.&lt;A href="http://database.windows.net" alt="http://database.windows.net" target="_blank"&gt;database.windows.net&lt;/A&gt;;loginTimeout=30;", "dbtable" -&amp;gt; s"$t_table"))&lt;/P&gt;&lt;P&gt;And in a SQL Notebook: CREATE TEMPORARY TABLE jdbcTable USING org.apache.spark.sql.jdbc OPTIONS ( url "jdbc:sqlserver://&lt;A href="http://xxxxx.databse.windows.net" alt="http://xxxxx.databse.windows.net" target="_blank"&gt;xxxxx.databse.windows.net&lt;/A&gt;;DabaseName=yyyydb01;user=someuser;password=secret", dbtable "SalesLT.Product")&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 22:48:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30019#M21700</guid>
      <dc:creator>Tamara</dc:creator>
      <dc:date>2015-11-06T22:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can I connect to a MS SQL server table in Databricks account?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30020#M21701</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;Few days ago I had to write some programs to connect with MS SQL.. &lt;/P&gt;&lt;P&gt;Here is quick snippet.. Enjoy!&lt;/P&gt;&lt;P&gt;Import the data from MS SQL Server and Export the CSV to file system (could be a mount pointing to S3 or any other location)&lt;/P&gt;&lt;P&gt;By default databrick cluster doesn't any jdbc driver for MS SQL Server by default so download the jar file (sqljdbc42.jar) from microsoft site &lt;A href="https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&amp;amp;id=11774" target="test_blank"&gt;https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&amp;amp;id=11774&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt; &amp;gt; &lt;P&gt;&lt;/P&gt; &lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;// Reference to correct driver class&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;import com.microsoft.sqlserver.jdbc.SQLServerDriver&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;import java.sql.DriverManager&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;import org.apache.spark.sql.SQLContext&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;import sqlContext.implicits._&lt;/CODE&gt;&lt;/PRE&gt; &lt;PRE&gt;&lt;CODE&gt;// MS SQL JDBC Connection String ... &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;val jdbcSqlConnStr = "jdbc:sqlserver://ServerIP:1433;databaseName=YourDBName;user=user1223;password=xxxxx;"&lt;/CODE&gt;&lt;/PRE&gt; &lt;PRE&gt;&lt;CODE&gt;// Loading the ms sql table via spark context into dataframe&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;val jdbcDF = sqlContext.read.format("jdbc").options(&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;  Map("url" -&amp;gt; jdbcSqlConnStr,&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;  "driver" -&amp;gt; "com.microsoft.sqlserver.jdbc.SQLServerDriver",&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;  "dbtable" -&amp;gt; "yourtablename")).load()&lt;/CODE&gt;&lt;/PRE&gt; &lt;PRE&gt;&lt;CODE&gt;// Registering the temp table so that we can SQL like query against the table &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;jdbcDF.registerTempTable("yourtablename")&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;// selecting only top 10 rows here but you can use any sql statement&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;val yourdata = sqlContext.sql("SELECT * FROM yourtablename LIMIT 10")&lt;/CODE&gt;&lt;/PRE&gt; &lt;PRE&gt;&lt;CODE&gt;// display the data &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;yourdata.show()&lt;/CODE&gt;&lt;/PRE&gt; &lt;PRE&gt;&lt;CODE&gt;// Simple write to mount location which could be pointing to S3 or any other storage &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;// If you planning to overwrite the same file then its important that you use overwrite&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;customerSumtop10.write.format("com.databricks.spark.csv").mode(SaveMode.Overwrite).option("header", "true").save("/yourmount/yourdata.csv") &lt;/P&gt; &lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2016 02:51:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30020#M21701</guid>
      <dc:creator>sanchand</dc:creator>
      <dc:date>2016-06-01T02:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can I connect to a MS SQL server table in Databricks account?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30021#M21702</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;sqlContext.load() - No more working&lt;/P&gt;
&lt;P&gt; var df1=sqlContext.read.format("jdbc").option("url","jdbc:sqlserver://localhost:1433;database=&lt;B&gt;&lt;/B&gt;").option("driver","com.microsoft.sqlserver.jdbc.SQLServerDriver").option("dbtable","&lt;B&gt;&lt;B&gt;tablename&lt;/B&gt;&lt;I&gt;").option("user","&lt;/I&gt;&lt;/B&gt;&lt;B&gt;").option("password","&lt;/B&gt;**").load()&lt;/P&gt;
&lt;P&gt;df1.show()&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 20:19:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30021#M21702</guid>
      <dc:creator>mgh</dc:creator>
      <dc:date>2016-11-03T20:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can I connect to a MS SQL server table in Databricks account?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30022#M21703</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;You're pointed at a local database - Databricks won't be able to read from localhost&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 16:09:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30022#M21703</guid>
      <dc:creator>Bill_Chambers</dc:creator>
      <dc:date>2016-11-04T16:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can I connect to a MS SQL server table in Databricks account?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30023#M21704</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Actually what i wanna mention is the change in the syntax, and I am using my server name instead of localhost.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 20:14:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30023#M21704</guid>
      <dc:creator>mgh</dc:creator>
      <dc:date>2016-11-04T20:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can I connect to a MS SQL server table in Databricks account?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30024#M21705</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Is there way to connect with AAD instead of SQL userid/password? &lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 17:41:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30024#M21705</guid>
      <dc:creator>ChadDotzenrod</dc:creator>
      <dc:date>2018-09-06T17:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can I connect to a MS SQL server table in Databricks account?</title>
      <link>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30025#M21706</link>
      <description>&lt;P&gt;Thanks for the trick that you have shared with us. I am really amazed to use this informational post. &lt;/P&gt;&lt;P&gt;If you are facing MacBook error like MacBook Pro won't turn on black screen then click the link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 09:19:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/can-i-connect-to-a-ms-sql-server-table-in-databricks-account/m-p/30025#M21706</guid>
      <dc:creator>JohnSmith091</dc:creator>
      <dc:date>2018-11-27T09:19:31Z</dc:date>
    </item>
  </channel>
</rss>

