Sqoop:从 Oracle 导入数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17023735/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sqoop : import data from Oracle
提问by user2462699
I try to use Sqoop to import data from an Oracle DB.
我尝试使用 Sqoop 从 Oracle DB 导入数据。
I have placed the Oracle JDBC Driver (ojdbc6.jar) into SQOOP_HOME/lib.
我已将 Oracle JDBC 驱动程序 (ojdbc6.jar) 放入 SQOOP_HOME/lib。
My JDK is 1.6 version.
我的JDK是1.6版本。
Here is my query :
这是我的查询:
sqoop import --hive-import --connect jdbc:oracle:thin@<ip_server>:1521/db --table ENTITE --username username --password password
But, when i launch the command, i get this error :
但是,当我启动命令时,出现此错误:
ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: oracle.jdbc.oracleDriver
java.lang.RuntimeException: Could not load db driver class: oracle.jdbc.oracleDriver
I don't understand why Sqoop can't connect to my db server.
我不明白为什么 Sqoop 无法连接到我的数据库服务器。
Thanks for your help
谢谢你的帮助
回答by user2480844
If your using sqoop 1.4.2 assuming based on ojdbc6.jar above then see comments about the --driver usage from Kathleen here as it shouldn't be required:
如果您使用基于 ojdbc6.jar 的 sqoop 1.4.2 假设,请在此处查看 Kathleen 关于 --driver 用法的评论,因为它不应该是必需的:
https://issues.apache.org/jira/browse/SQOOP-457
https://issues.apache.org/jira/browse/SQOOP-457
With sqoop 1.4.2 and dropping ojdbc6.jar into my sqoop/lib this string works w/HDP 1.3 and MapR 2.0:
使用 sqoop 1.4.2 并将 ojdbc6.jar 放入我的 sqoop/lib 中,此字符串适用于 HDP 1.3 和 MapR 2.0:
sqoop import --connect "jdbc:oracle:thin:@(description=(address=(protocol=tcp)(host=myhost)(port=1521))(connect_data=(service_name=myservice)))" \
--username USER --table SCHEMA.TABLE_NAME --hive-import --hive-table SCHEMA.TABLE_NAME \
--num-mappers 1 --verbose -P \
If you have access to mysql and or sql server, etc. test those too and make sure your lib directory is getting picked up. SQL Server is / was supposed to be in sqoop 1.4, but the docs and attempting to use it proved otherwise:
如果您有权访问 mysql 和/或 sql server 等,也请测试它们并确保您的 lib 目录被选中。SQL Server 应该在 sqoop 1.4 中,但文档和尝试使用它证明并非如此:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=11774- here is what you want for sql server testing.
http://www.microsoft.com/en-us/download/confirmation.aspx?id=11774- 这是您想要的 sql server 测试。
cheers.
干杯。
回答by Khaled Annajar
You need to add the oracle jdbc driver inside sqoop lib directory
您需要在 sqoop lib 目录中添加 oracle jdbc 驱动程序
回答by GURUVEER
You have to download the oracle connector jar file and copy that jar file to lib folder of Sqoop.
您必须下载 oracle 连接器 jar 文件并将该 jar 文件复制到 Sqoop 的 lib 文件夹中。
The jar file can be downloaded from http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
jar 文件可以从http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html下载
copy this jar file to your Sqoop lib folder (/usr/lib/sqoop/lib)
将此 jar 文件复制到您的 Sqoop lib 文件夹 (/usr/lib/sqoop/lib)
And run the sqoop command.
并运行 sqoop 命令。
回答by Nirmal
oracle ojdbc6.jar needs to be copied to sqoop/lib directory to make it work.
oracle ojdbc6.jar 需要复制到sqoop/lib 目录下才能运行。
回答by Eisen Stark
look at the error message: Could not load db driver class: oracle.jdbc.oracleDriver You need to type oracle.jdbc.OracleDriver with high register "O", since java is case sensitive
查看错误信息:Could not load db driver class: oracle.jdbc.oracleDriver You need to type oracle.jdbc.OracleDriver with high register "O", 因为java区分大小写
回答by Sudhakar V
Check your sqoop classpath by adding echo and make sure your driver is on the classpath. Same problem I have faced and resolved it.
通过添加 echo 检查您的 sqoop 类路径,并确保您的驱动程序在类路径上。我遇到并解决了同样的问题。
回答by Reddevil
The error says that sqoop can't load oracle driver class as there is no ojdbc driver jar file in its path.First, You have to add ojdbc driver jar to lib folder of your sqoop home. Please download it here
该错误表示sqoop无法加载oracle驱动程序类,因为其路径中没有ojdbc驱动程序jar文件。首先,您必须将ojdbc驱动程序jar添加到sqoop主目录的lib文件夹中。请在这里下载
http://www.java2s.com/Code/Jar/o/Downloadojdbc6jar.htm
回答by user2320426
You can state the oracle driver you use like so
您可以像这样说明您使用的 oracle 驱动程序
sqoop import --hive-import --driver oracle.jdbc.driver.oracledriver --connect jdbc:oracle:thin@<ip_server>:1521/db --table ENTITE --username username --password password
sqoop import --hive-import --driver oracle.jdbc.driver.oracledriver --connect jdbc:oracle:thin@<ip_server>:1521/db --table ENTITE --username username --password password
回答by umerayazbaig
sqoop import --connect "jdbc:oracle:thin:@(description=(address=(protocol=tcp)(host=hostip)(port=1521))(connect_data=(service_name=servicename)))" --username user --password pwd --table schema.tablename --hive-import --num-mappers 1 --verbose -P
sqoop import --connect "jdbc:oracle:thin:@(description=(address=(protocol=tcp)(host=hostip)(port=1521))(connect_data=(service_name=servicename)))" --username 用户--password pwd --table schema.tablename --hive-import --num-mappers 1 --verbose -P