mysql - Sqoop from within a Java program -


i have read questions on using sqoop within java program here, here , here.

i came following, stumped classnotfoundexception:

import org.apache.hadoop.conf.configuration; import org.apache.hadoop.fs.*;  import com.cloudera.sqoop.sqoopoptions; import com.cloudera.sqoop.sqoopoptions.filelayout;  import com.mysql.jdbc.*;  public class sqoopexample {     public static void main(string[] args) throws exception {         string driver = "com.mysql.jdbc.driver";         class.forname(driver);          configuration config = new configuration();         // note hdfs path, rather core path         config.addresource(new path("./config/core-site.xml"));         config.addresource(new path("./config/hdfs-site.xml"));         filesystem dfs = filesystem.get(config);              sqoopoptions options = new sqoopoptions();         options.setdriverclassname(driver);         options.setconnectstring("jdbc:mysql://localhost:3306/dbname");         options.settablename("v_webstats");         options.setusername("root");         options.setnummappers(1);          options.settargetdir(dfs.getworkingdirectory()+"/testdirectory");         options.setfilelayout(filelayout.textfile);          new com.cloudera.sqoop.tool.importtool().run(options);     } } 

i sure jars correctly included , have tested connection database server , works well.

the exact error is:

exception in thread "main" java.lang.classnotfoundexception: com.mysql.jdbc.driver     @ java.net.urlclassloader$1.run(unknown source)     @ java.net.urlclassloader$1.run(unknown source)     @ java.security.accesscontroller.doprivileged(native method)     @ java.net.urlclassloader.findclass(unknown source)     @ java.lang.classloader.loadclass(unknown source)     @ sun.misc.launcher$appclassloader.loadclass(unknown source)     @ java.lang.classloader.loadclass(unknown source)     @ java.lang.class.forname0(native method)     @ java.lang.class.forname(unknown source)     @ sqoopexample.main(sqoopexample.java:14) 

not sure doing wrong.

i believe proper name of mysql jdbc driver class is:

com.mysql.jdbc.driver

(notice capital "d" in "driver)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -