Netezza connection with Spark / Scala JDBC -


i've set spark 2.2.0 on windows machine using scala 2.11.8 on intellij ide. i'm trying make spark connect netezza using jdbc drivers.

i've read through this link , added com.ibm.spark.netezzajars project through maven. attempt run scala script below test connection:

package jdbc object simplescalaspark {   def main(args: array[string]) {     import org.apache.spark.sql.{sparksession, sqlcontext}     import com.ibm.spark.netezza      val spark = sparksession.builder       .master("local")       .appname("simplescalaspark")       .getorcreate()      val sqlcontext = sparksession.builder()       .appname("simplescalaspark")       .master("local")       .getorcreate()  val nzoptions = map("url" -> "jdbc:netezza://server:5480/database",   "user" -> "user",   "password" -> "password",   "dbtable" -> "admin.tablename")  val df = sqlcontext.read.format("com.ibm.spark.netezza").options(nzoptions).load()   } } 

however following error:

17/07/27 16:28:17 error netezzajdbcutils$: couldn't find class org.netezza.driver java.lang.classnotfoundexception: org.netezza.driver     @ java.net.urlclassloader.findclass(urlclassloader.java:381)     @ java.lang.classloader.loadclass(classloader.java:424)     @ sun.misc.launcher$appclassloader.loadclass(launcher.java:335)     @ java.lang.classloader.loadclass(classloader.java:357)     @ org.apache.spark.sql.execution.datasources.jdbc.driverregistry$.register(driverregistry.scala:38)     @ com.ibm.spark.netezza.netezzajdbcutils$$anonfun$getconnector$1.apply(netezzajdbcutils.scala:49)     @ com.ibm.spark.netezza.netezzajdbcutils$$anonfun$getconnector$1.apply(netezzajdbcutils.scala:46)     @ com.ibm.spark.netezza.defaultsource.createrelation(defaultsource.scala:50)     @ org.apache.spark.sql.execution.datasources.datasource.resolverelation(datasource.scala:306)     @ org.apache.spark.sql.dataframereader.load(dataframereader.scala:178)     @ org.apache.spark.sql.dataframereader.load(dataframereader.scala:146)     @ jdbc.simplescalaspark$.main(simplescalaspark.scala:20)     @ jdbc.simplescalaspark.main(simplescalaspark.scala) exception in thread "main" java.sql.sqlexception: no suitable driver found jdbc:netezza://server:5480/database     @ java.sql.drivermanager.getconnection(drivermanager.java:689)     @ java.sql.drivermanager.getconnection(drivermanager.java:208)     @ com.ibm.spark.netezza.netezzajdbcutils$$anonfun$getconnector$1.apply(netezzajdbcutils.scala:54)     @ com.ibm.spark.netezza.netezzajdbcutils$$anonfun$getconnector$1.apply(netezzajdbcutils.scala:46)     @ com.ibm.spark.netezza.defaultsource.createrelation(defaultsource.scala:50)     @ org.apache.spark.sql.execution.datasources.datasource.resolverelation(datasource.scala:306)     @ org.apache.spark.sql.dataframereader.load(dataframereader.scala:178)     @ org.apache.spark.sql.dataframereader.load(dataframereader.scala:146)     @ jdbc.simplescalaspark$.main(simplescalaspark.scala:20)     @ jdbc.simplescalaspark.main(simplescalaspark.scala) 

i have 2 ideas:

1) don't don't believe installed netezza jdbc driver, though thought jars brought project link above sufficient. missing driver or missing in scala script?

2) in same link, author makes mention of starting netezza spark package:

for example, use spark netezza package spark’s interactive shell, start shown below:

$spark_home/bin/spark-shell –packages com.ibm.sparktc:spark-netezza_2.10:0.1.1 –driver-class-path~/nzjdbc.jar

i don't believe i'm invoking package apart jdbc in script. have add script?

thanks!

your 1st idea right, think. need install netezza jdbc driver if have not done already.

from link posted:

this package can deployed part of application program or spark tools such spark-shell, spark-sql. use package in application, have specify in application’s build dependency. when using spark tools, add package using –packages command line option. netezza jdbc driver should added application dependencies.

the netezza driver have download yourself, , need support entitlement access (via ibm's fix central or passport advantage). included in either windows driver/client support package, or linux driver package.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -