0

I am able to import data from sql server to hive using sqoop in command prompt as below:

>sqoop import --connect jdbc:sqlserver://localhost --username pavan -P --table my_Practice --hive-table my_Table --create-hive-table --hive-import -m 1

But i need to do the same using Java. Can anyone suggest me how to import the data using sqoop in Java??

Pavan
  • 1
  • 4
  • Are you looking for a way to [execute system commands using java](http://stackoverflow.com/questions/792024/how-to-execute-system-commands-linux-bsd-using-java) ? – Suvarna Pattayil Jan 09 '14 at 09:15
  • No not the system commands.@VusP – Pavan Jan 09 '14 at 11:04
  • You can [Edit](http://stackoverflow.com/posts/21012058/edit) the question and add your code to it. – Suvarna Pattayil Jan 09 '14 at 11:07
  • I used the below code: com.cloudera.sqoop.SqoopOptions options = new com.cloudera.sqoop.SqoopOptions(); options.setConnectString("jdbc:sqlserver://localhost"); options.setUsername("Pavan"); options.setPassword("*******"); options.setTableName("testtable"); options.setNumMappers(1); options.setHiveTableName("testdata"); options.setHiveImport(true); options.setOverwriteHiveTable(true); int ret = new ImportTool().run(options); – Pavan Jan 09 '14 at 11:09
  • ERROR manager.SqlManager: Error executing statement: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'testtable'. com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'testtable' ERROR tool.ImportTool: Imported Failed: Attempted to generate class with no columns! – Pavan Jan 09 '14 at 11:10

0 Answers0