<?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: An example how to connect to SQL Server data using windows authentication in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/22018#M15037</link>
    <description>&lt;P&gt;You can use jTDS library from maven, add this to your cluster. Once installed, you can write the below code to connect to your Database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code in Scala will be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import java.util.Properties
&amp;nbsp;
val driverClass = "net.sourceforge.jtds.jdbc.Driver"
val serverAdd = ""
val databaseName = ""
val domain = "" // use domain of your active directory
val database_port = ""
&amp;nbsp;
val jdbcUsername = "" 
val jdbcPassword = ""
&amp;nbsp;
val conStr = "jdbc:jtds:sqlserver://"+ serverAdd + ":" + database_port +"/" + databaseName + ";useNTLMv2=true;domain=" + domain  + ";"
&amp;nbsp;
val connectionProperties = new Properties()
connectionProperties.put("user",s"${jdbcUsername}")
connectionProperties.put("password",s"${jdbcPassword}")
connectionProperties.setProperty("Driver", driverClass)
&amp;nbsp;
&amp;nbsp;
val dataFrame = spark.read.jdbc(url = conStr,  
                                table = "(select * from table_name) a",
                                properties = connectionProperties)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jun 2022 12:50:14 GMT</pubDate>
    <dc:creator>Junee</dc:creator>
    <dc:date>2022-06-29T12:50:14Z</dc:date>
    <item>
      <title>An example how to connect to SQL Server data using windows authentication</title>
      <link>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/22017#M15036</link>
      <description>&lt;P&gt;We use SQL Server to store data.  I would like to connect to SQL to pull manipulate and sometimes push data back.  I've seen some examples online of connecting but I cannot successfully re-create.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 15:12:51 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/22017#M15036</guid>
      <dc:creator>gillzer84</dc:creator>
      <dc:date>2022-04-27T15:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: An example how to connect to SQL Server data using windows authentication</title>
      <link>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/22018#M15037</link>
      <description>&lt;P&gt;You can use jTDS library from maven, add this to your cluster. Once installed, you can write the below code to connect to your Database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code in Scala will be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import java.util.Properties
&amp;nbsp;
val driverClass = "net.sourceforge.jtds.jdbc.Driver"
val serverAdd = ""
val databaseName = ""
val domain = "" // use domain of your active directory
val database_port = ""
&amp;nbsp;
val jdbcUsername = "" 
val jdbcPassword = ""
&amp;nbsp;
val conStr = "jdbc:jtds:sqlserver://"+ serverAdd + ":" + database_port +"/" + databaseName + ";useNTLMv2=true;domain=" + domain  + ";"
&amp;nbsp;
val connectionProperties = new Properties()
connectionProperties.put("user",s"${jdbcUsername}")
connectionProperties.put("password",s"${jdbcPassword}")
connectionProperties.setProperty("Driver", driverClass)
&amp;nbsp;
&amp;nbsp;
val dataFrame = spark.read.jdbc(url = conStr,  
                                table = "(select * from table_name) a",
                                properties = connectionProperties)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 12:50:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/22018#M15037</guid>
      <dc:creator>Junee</dc:creator>
      <dc:date>2022-06-29T12:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: An example how to connect to SQL Server data using windows authentication</title>
      <link>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/22019#M15038</link>
      <description>&lt;P&gt;Would someone provide example with IntegratedSecurity instead of user name and passworld? &lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 14:52:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/22019#M15038</guid>
      <dc:creator>DBXC</dc:creator>
      <dc:date>2023-04-26T14:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: An example how to connect to SQL Server data using windows authentication</title>
      <link>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/22020#M15039</link>
      <description>&lt;P&gt;*password*&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 14:52:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/22020#M15039</guid>
      <dc:creator>DBXC</dc:creator>
      <dc:date>2023-04-26T14:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: An example how to connect to SQL Server data using windows authentication</title>
      <link>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/101404#M40649</link>
      <description>&lt;P&gt;Thanks, this worked for me.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 05:11:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/an-example-how-to-connect-to-sql-server-data-using-windows/m-p/101404#M40649</guid>
      <dc:creator>rdc14</dc:creator>
      <dc:date>2024-12-09T05:11:20Z</dc:date>
    </item>
  </channel>
</rss>

