You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by "Devi P.V" <de...@gmail.com> on 2016/08/08 07:44:22 UTC

What are the configurations needs to connect spark and ms-sql server?

Hi all,

I am trying to write a spark dataframe into MS-Sql Server.I have tried
using the following code,

 val sqlprop = new java.util.Properties
    sqlprop.setProperty("user","uname")
    sqlprop.setProperty("password","pwd")

sqlprop.setProperty("driver","com.microsoft.sqlserver.jdbc.SQLServerDriver")
    val url = "jdbc:sqlserver://samplesql.amazonaws.com:1433/dbName"
    val dfWriter = df.write
    dfWriter.jdbc(url, "tableName", sqlprop)

But I got following error

Exception in thread "main" java.lang.ClassNotFoundException:
com.microsoft.sqlserver.jdbc.SQLServerDriver

what are the configurations needs to connect to MS-Sql Server.Not found any
library dependencies for connecting spark and MS-Sql.

Thanks

Re: What are the configurations needs to connect spark and ms-sql server?

Posted by Deepak Sharma <de...@gmail.com>.
Hi Devi
Please make sure the jdbc jar is in the spark classpath.
With spark-submit , you can use --jars option to specify the sql server
jdbc jar.

Thanks
Deepak

On Mon, Aug 8, 2016 at 1:14 PM, Devi P.V <de...@gmail.com> wrote:

> Hi all,
>
> I am trying to write a spark dataframe into MS-Sql Server.I have tried
> using the following code,
>
>  val sqlprop = new java.util.Properties
>     sqlprop.setProperty("user","uname")
>     sqlprop.setProperty("password","pwd")
>     sqlprop.setProperty("driver","com.microsoft.sqlserver.jdbc.
> SQLServerDriver")
>     val url = "jdbc:sqlserver://samplesql.amazonaws.com:1433/dbName"
>     val dfWriter = df.write
>     dfWriter.jdbc(url, "tableName", sqlprop)
>
> But I got following error
>
> Exception in thread "main" java.lang.ClassNotFoundException:
> com.microsoft.sqlserver.jdbc.SQLServerDriver
>
> what are the configurations needs to connect to MS-Sql Server.Not found
> any library dependencies for connecting spark and MS-Sql.
>
> Thanks
>



-- 
Thanks
Deepak
www.bigdatabig.com
www.keosha.net