请提供以下问题的解决方案我正在使用com.microsoft.sqlserver.jdbc.SQLServerDriver访问spark项目中的数据,代码如下,
val jdbcDF = sqlContext.read
.format("jdbc")
.option("driver" , "com.microsoft.sqlserver.jdbc.SQLServerDriver")
.option("url", "jdbc:sqlserver://127.0.0.1/sparkDB")
.option("dbtable", " SELECT * FROM test_table" )
.option("user", "sa")
.option("password", "User@123456")
.load()但是我得到了以下错误
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException:
The TCP/IP connection to
the host 127.0.0.1/sparkDB, port 1433 has failed. Error:
"127.0.0.1/sparkDB. Verify the connection properties. Make sure that an
instance of SQL Server is running on the host and accepting TCP/IP
connections at the port. Make sure that TCP connections to the port are not
blocked by a firewall.".当我的防火墙关闭的时候。
发布于 2017-12-14 08:22:23
尝试使用
val jdbcDF = sqlContext.read
.format("jdbc")
.option("driver" , "com.microsoft.sqlserver.jdbc.SQLServerDriver")
.option("url", "jdbc:sqlserver://127.0.0.1\\sparkDB")
.option("dbtable", " (SELECT * FROM test_table) AS Q" )
.option("user", "sa")
.option("password", "User@123456")
.load()或
val jdbcDF = sqlContext.read
.format("jdbc")
.option("driver" , "com.microsoft.sqlserver.jdbc.SQLServerDriver")
.option("url", "jdbc:sqlserver://127.0.0.1;instancename=sparkDB")
.option("dbtable", " (SELECT * FROM test_table) AS Q" )
.option("user", "sa")
.option("password", "User@123456")
.load()https://stackoverflow.com/questions/45960240
复制相似问题