[英]spark and aws redshift: java.sql.SQLException: No suitable driver found for jdbc:redshift://xxx.us-west-2.redshift.amazonaws.com:5439
os: centos os:centos
spark:1.6.1 火花:1.6.1
sbt: build.sbt sbt:build.sbt
libraryDependencies ++= {
Seq(
"org.apache.spark" %% "spark-core" % "1.6.1" % "provided",
"com.amazonaws" % "aws-java-sdk" % "1.10.75",
"com.amazonaws" % "amazon-kinesis-client" % "1.1.0",
"com.amazon.redshift" % "jdbc4" % "1.1.7.1007" % "test"
)
}
resolvers ++= Seq(
"redshift" at "https://s3.amazonaws.com/redshift-downloads/drivers/RedshiftJDBC4-1.1.7.1007.jar"
)
spark app: 火花应用:
val redshiftDriver = "com.amazon.redshift.jdbc4.Driver"
Class.forName(redshiftDriver)
I've specified the redshift driver, and updated to url etc., following AWS official documentation here: http://docs.aws.amazon.com/redshift/latest/mgmt/connecting-in-code.html 我已经在此处的AWS官方文档中指定了redshift驱动程序并更新为url等: http : //docs.aws.amazon.com/redshift/latest/mgmt/connecting-in-code.html
But I'm still getting error below: 但我仍然得到以下错误:
java.sql.SQLException: No suitable driver found for jdbc:redshift://xxx.us-west-2.redshift.amazonaws.com:5439
I googled and someone said the jar should be added to classpath? 我用谷歌搜索,有人说罐子应该添加到classpath? Could anyone please help here?
有人可以帮忙吗? Thank you very much
非常感谢你
Solved : 解决了 :
just clean all cached stuff , and re-build everything from scratch, and then it's working 只需清理所有缓存的东西 ,然后从头开始重新构建所有内容,然后就可以了
Add on: 添加在:
Databricks implemented this lib, which could make our life much easier interacting redshift within Spark https://github.com/databricks/spark-redshift Databricks实现了这个lib,这可以让我们的生活更轻松地在Spark内部进行红移互动https://github.com/databricks/spark-redshift
// Get some data from a Redshift table
val df: DataFrame = sqlContext.read
.format("com.databricks.spark.redshift")
.option("url", "jdbc:redshift://redshifthost:5439/database?user=username&password=pass")
.option("dbtable", "my_table")
.option("tempdir", "s3n://path/for/temp/data")
.load()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.