SQOOP SQLSERVER未能加载驱动程序“适当的连接管理器未被设置”

时间:2022-09-22 20:48:48

I downloaded sqljdbc4.jar. I'm invoking sqoop like so from the folder (where the jar is stored):

我下载sqljdbc4.jar。我从文件夹(存储jar的地方)调用sqoop:

sqoop list-tables --driver com.microsoft.jdbc.sqlserver.SQLServerDriver --connect jdbc:sqlserver://localhost:1433;user=me;password=myPassword; -libjars=./sqljdbc4.jar

sqoop list-tables com.microsoft.jdbc.sqlserver——驱动程序。SQLServerDriver——连接jdbc::状态"置疑" / / localhost:1433;用户=我;密码=我的密码;-libjars =。/ sqljdbc4.jar

I'm getting the following warning & error:

我得到以下警告和错误:

13/10/25 18:38:13 WARN sqoop.ConnFactory: Parameter --driver is set to an explicit driver however appropriate connection manager is not being set (via --connection-manager). Sqoop is going to fall back to org.apache.sqoop.manager.GenericJdbcManager. Please specify explicitly which connection manager should be used next time.

13/10/25 18:38:13警告sqoop。ConnFactory:参数——驱动程序被设置为显式驱动程序,但是不设置适当的连接管理器(通过-连接-管理器)。Sqoop将回落到org.apache.sqoop.manager.GenericJdbcManager。请明确指定下次使用哪个连接管理器。

13/10/25 18:38:13 INFO manager.SqlManager: Using default fetchSize of 1000
13/10/25 18:38:13 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.microsoft.jdbc.sqlserver.SQLServerDriver
java.lang.RuntimeException: Could not load db driver class: com.microsoft.jdbc.sqlserver.SQLServerDriver
    at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:727)
    at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
    at org.apache.sqoop.manager.SqlManager.listTables(SqlManager.java:418)
    at org.apache.sqoop.tool.ListTablesTool.run(ListTablesTool.java:49)
    at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
    at org.apache.sqoop.Sqoop.main(Sqoop.java:238)

UPDATE

更新

I changed the command line to reflect the comments below, I get the same error:

我更改了命令行,以反映下面的注释,我得到了相同的错误:

sqoop list-databases -libjars=<ABSOLUTE_PATH>/jars/sqljdbc4.jar --connect jdbc:sqlserver://localhost:1433;user=me;password=password

sqoop list-databases -libjars = < ABSOLUTE_PATH > /罐/ sqljdbc4。jar——连接jdbc::状态"置疑" / / localhost:1433;用户=我;密码=密码

13/10/28 17:00:33 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
java.lang.RuntimeException: Could not load db driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
    at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:727)
    at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
    at org.apache.sqoop.manager.CatalogQueryManager.listDatabases(CatalogQueryManager.java:57)
    at org.apache.sqoop.tool.ListDatabasesTool.run(ListDatabasesTool.java:49)
    at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
    at org.apache.sqoop.Sqoop.main(Sqoop.java:238)

When I look at the listing of sqljdbc4.jar, I do see the class in that path... Is it possible that libjars option isn't doing what I think it is supposed to do?

当我查看sqljdbc4的列表时。jar,我确实看到了这条路径上的类…是否有可能libjars选项没有执行我认为应该做的事情?

3 个解决方案

#1


3  

In vast majority of cases using parameter --driver is not required and even more will lead to an undesirable behaviour. I would strongly recommend dropping this argument entirely from your command line. Check out Connectors vs Drivers blog post for more details.

在绝大多数情况下,使用参数——驱动程序不是必需的,甚至更多将导致不良行为。我强烈建议您完全放弃您的命令行。查看连接器和驱动程序博客文章,了解更多细节。

Also in addition you are specifying a nonexistent JDBC Driver class. The correct one is:

另外,您还指定了一个不存在的JDBC驱动程序类。正确的是:

com.microsoft.sqlserver.jdbc.SQLServerDriver

You can see it in the official docs, whereas you are specifying

您可以在官方文档中看到它,而您正在指定。

com.microsoft.jdbc.sqlserver.SQLServerDriver

Notice the different order of jdbc and sqlserver packages. This is one of the reasons why it's recommended to not use the --driver option at all.

注意jdbc和sqlserver包的不同顺序。这就是为什么建议不要使用驱动程序的原因之一。

#2


3  

You need to put sqljdbc4.jar in $SQOOP_HOME/lib and also add sqoop-1.4.4.jar or whatever version you are using along with sqljdbc4.jar to $HADOOP_HOME/lib.

您需要输入sqljdbc4。jar在$SQOOP_HOME/lib中,还添加了sqoop-1.4.4。jar或其他与sqljdbc4一起使用的版本。jar $ HADOOP_HOME / lib。

I'm using Hadoop-2.2.0, so i put it inside $HADOOP_HOME/share/hadoop/common/lib directory, and use the following command to do the import:

我使用hadoop -2.2.0,所以我将它放入$ hadoop home /share/hadoop/common/lib目录中,并使用以下命令进行导入:

export HCAT_HOME=/home/Kuntal/BIG_DATA/hive-0.12.0/hcatalog

出口HCAT_HOME = / home / Kuntal / BIG_DATA hive-0.12.0 / hcatalog

(sometimes HCatlog of Hive needs to be exported or set.)

(有时需要导出或设置蜂箱的HCatlog。)

./sqoop-import --connect "jdbc:sqlserver://IP\INSTANCE;port=1433;username=USERNAME;password=PASSWORD;database=DATABASE_NAME" --table TABLE_NAME --target-dir hdfs://localhost:50315/sqoop --m 1

./sqoop-import——连接“jdbc:sqlserver://IP\实例;端口=1433;用户名=用户名;密码=密码;数据库=DATABASE_NAME”—table TABLE_NAME—target-dir hdfs://localhost:50315/sqoop—m1。

Sometimes you have to specify the port, otherwise default works. Hope you find it useful.

有时您必须指定端口,否则默认工作。希望你觉得它有用。

#3


2  

According to this sqoop documentation, generic options like -libjars must come before tool-specific options:

根据这个sqoop文档,像-libjar这样的通用选项必须在工具特定的选项之前出现:

Generic Hadoop command-line arguments:
(must preceed any tool-specific arguments)
...
-libjars <comma separated list of jars> specify comma separated jar files to include in the classpath.

通用的Hadoop命令行参数:(必须在任何特定于工具的参数之前)…-libjars <逗号分隔的jar列表,在类路径中指定逗号分隔的jar文件。< p>

#1


3  

In vast majority of cases using parameter --driver is not required and even more will lead to an undesirable behaviour. I would strongly recommend dropping this argument entirely from your command line. Check out Connectors vs Drivers blog post for more details.

在绝大多数情况下,使用参数——驱动程序不是必需的,甚至更多将导致不良行为。我强烈建议您完全放弃您的命令行。查看连接器和驱动程序博客文章,了解更多细节。

Also in addition you are specifying a nonexistent JDBC Driver class. The correct one is:

另外,您还指定了一个不存在的JDBC驱动程序类。正确的是:

com.microsoft.sqlserver.jdbc.SQLServerDriver

You can see it in the official docs, whereas you are specifying

您可以在官方文档中看到它,而您正在指定。

com.microsoft.jdbc.sqlserver.SQLServerDriver

Notice the different order of jdbc and sqlserver packages. This is one of the reasons why it's recommended to not use the --driver option at all.

注意jdbc和sqlserver包的不同顺序。这就是为什么建议不要使用驱动程序的原因之一。

#2


3  

You need to put sqljdbc4.jar in $SQOOP_HOME/lib and also add sqoop-1.4.4.jar or whatever version you are using along with sqljdbc4.jar to $HADOOP_HOME/lib.

您需要输入sqljdbc4。jar在$SQOOP_HOME/lib中,还添加了sqoop-1.4.4。jar或其他与sqljdbc4一起使用的版本。jar $ HADOOP_HOME / lib。

I'm using Hadoop-2.2.0, so i put it inside $HADOOP_HOME/share/hadoop/common/lib directory, and use the following command to do the import:

我使用hadoop -2.2.0,所以我将它放入$ hadoop home /share/hadoop/common/lib目录中,并使用以下命令进行导入:

export HCAT_HOME=/home/Kuntal/BIG_DATA/hive-0.12.0/hcatalog

出口HCAT_HOME = / home / Kuntal / BIG_DATA hive-0.12.0 / hcatalog

(sometimes HCatlog of Hive needs to be exported or set.)

(有时需要导出或设置蜂箱的HCatlog。)

./sqoop-import --connect "jdbc:sqlserver://IP\INSTANCE;port=1433;username=USERNAME;password=PASSWORD;database=DATABASE_NAME" --table TABLE_NAME --target-dir hdfs://localhost:50315/sqoop --m 1

./sqoop-import——连接“jdbc:sqlserver://IP\实例;端口=1433;用户名=用户名;密码=密码;数据库=DATABASE_NAME”—table TABLE_NAME—target-dir hdfs://localhost:50315/sqoop—m1。

Sometimes you have to specify the port, otherwise default works. Hope you find it useful.

有时您必须指定端口,否则默认工作。希望你觉得它有用。

#3


2  

According to this sqoop documentation, generic options like -libjars must come before tool-specific options:

根据这个sqoop文档,像-libjar这样的通用选项必须在工具特定的选项之前出现:

Generic Hadoop command-line arguments:
(must preceed any tool-specific arguments)
...
-libjars <comma separated list of jars> specify comma separated jar files to include in the classpath.

通用的Hadoop命令行参数:(必须在任何特定于工具的参数之前)…-libjars <逗号分隔的jar列表,在类路径中指定逗号分隔的jar文件。< p>