Hey there, What are you trying to achieve exactly? It seems like you are extending Sqoop2 instead of using its Java client?
-Abe On Wed, Dec 3, 2014 at 1:04 AM, 呂佳鴻 <[email protected]> wrote: > hi , i have problem in using sqoop java api. > First, I add dependency to sqoop (sqoop/shell/pom.xml) > and run command: mvn install > (Is it correct ?) > > Here is the testing code i use > > import org.apache.sqoop.client.SqoopClient; > import org.apache.sqoop.model.MConnection; > import org.apache.sqoop.model.MConnectionForms; > import org.apache.sqoop.model.MJob; > import org.apache.sqoop.model.MJobForms; > import org.apache.sqoop.model.MSubmission; > import org.apache.sqoop.submission.counter.Counter; > import org.apache.sqoop.submission.counter.CounterGroup; > import org.apache.sqoop.submission.counter.Counters; > import org.apache.sqoop.validation.Status; > import org.apache.sqoop.*; > public class SqoopAccess{ > public static void main(String[] args){ > String url = "http://localhost:12000/sqoop/"; > SqoopClient client = new SqoopClient(url); > client.setServerUrl(url); > MConnection newCon = client.newConnection(1); > > MConnectionForms conForms = newCon.getConnectorPart(); > MConnectionForms frameworkForms = newCon.getFrameworkPart(); > newCon.setName("MyConnection"); > > conForms.getStringInput("connection.connectionString").setValue("jdbc:mysql://localhost/sqoop_test"); > > conForms.getStringInput("connection.jdbcDriver").setValue("com.mysql.jdbc.Driver"); > conForms.getStringInput("connection.username").setValue("root"); > conForms.getStringInput("connection.password").setValue("root"); > frameworkForms.getIntegerInput("security.maxConnections").setValue(0); > } > } > > > when i run, i got the exception > > Exception in thread "main" java.lang.NoClassDefFoundError: > org/apache/sqoop/common/ErrorCode > at SqoopAccess.main(SqoopAccess.java:15) > Caused by: java.lang.ClassNotFoundException: > org.apache.sqoop.common.ErrorCode > at java.net.URLClassLoader$1.run(URLClassLoader.java:372) > at java.net.URLClassLoader$1.run(URLClassLoader.java:361) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:360) > at java.lang.ClassLoader.loadClass(ClassLoader.java:424) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) > at java.lang.ClassLoader.loadClass(ClassLoader.java:357) > ... 1 more > > Which part is incorrect? > I'm no idea for how to use it . > Is any sample i can find or use on the website? > Thanks. >
