1、问题描述

(1)问题示例:

[Hadoop@master TestDir]$ sqoop list-databases --connect jdbc:mysql://master:3306/ --username Hive --password ******
2021-11-05 16:18:52,289 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
2021-11-05 16:18:52,316 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2021-11-05 16:18:52,379 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at org.apache.sqoop.manager.MySQLManager.initOptionDefaults(MySQLManager.java:73)
at org.apache.sqoop.manager.SqlManager.<init>(SqlManager.java:89)
at com.cloudera.sqoop.manager.SqlManager.<init>(SqlManager.java:33)
at org.apache.sqoop.manager.GenericJdbcManager.<init>(GenericJdbcManager.java:51)
at com.cloudera.sqoop.manager.GenericJdbcManager.<init>(GenericJdbcManager.java:30)
at org.apache.sqoop.manager.CatalogQueryManager.<init>(CatalogQueryManager.java:46)
at com.cloudera.sqoop.manager.CatalogQueryManager.<init>(CatalogQueryManager.java:31)
at org.apache.sqoop.manager.InformationSchemaManager.<init>(InformationSchemaManager.java:38)
at com.cloudera.sqoop.manager.InformationSchemaManager.<init>(InformationSchemaManager.java:31)
at org.apache.sqoop.manager.MySQLManager.<init>(MySQLManager.java:65)
at org.apache.sqoop.manager.DefaultManagerFactory.accept(DefaultManagerFactory.java:67)
at org.apache.sqoop.ConnFactory.getManager(ConnFactory.java:184)
at org.apache.sqoop.tool.BaseSqoopTool.init(BaseSqoopTool.java:272)
at org.apache.sqoop.tool.ListDatabasesTool.run(ListDatabasesTool.java:44)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
at org.apache.sqoop.Sqoop.main(Sqoop.java:252)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 20 more

(2)问题综述:

命令:sqoop list-databases --connect jdbc:mysql://master:3306/ --username Hive --password ******

上述命令,是用于查看MySQL已有的数据库。不能成功连接,不能显示出MySQL中已有数据库。

2、解决方案

参考:https://www.cndba.cn/dave/article/3303

(1)根据参考,下载驱动包:commons-lang-2.6.jar

下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache//commons/lang/binaries/commons-lang-2.6-bin.zip

下载地址可能存在失效,只需要找到commons-lang-2.6.jar

(2)上述下载压缩包:commons-lang-2.6-bin.zip,须解压,然后将其中的“commons-lang-2.6.jar”拷贝至Sqoop中lib中。

(3)再次测试:

[Hadoop@master TestDir]$ sqoop list-databases --connect jdbc:mysql://master:3306/ --username Hive --password ******
2021-11-05 17:07:59,566 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
2021-11-05 17:07:59,584 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2021-11-05 17:07:59,645 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
mysql
information_schema
performance_schema
sys
Test
source
hive

上述测试,成功查看MySQL中数据库,说明问题已解决。

3、问题剖析

原因是:笔者所安装的Sqoop版本为sqoop-1.4.7,缺少驱动包:commons-lang-2.6.jar,已存在commons-lang3-3.4.jar不合适。

因此需要另外下载驱动包:commons-lang-2.6.jar。

Sqoop连接数据库MySQL报错的更多相关文章

  1. Java项目连接数据库Mysql报错create connection SQLException

    今天编写了一个Java项目,对数据库Mysql的表进行增删改查,然后遇到了这个问题 严重: create connection SQLException, url: jdbc:mysql://loca ...

  2. 安装mysql报错

    原文链接:https://blog.csdn.net/bao19901210/article/details/51917641 二进制安装 1.添加mysql组和mysql用户,用于设置mysql安装 ...

  3. PHP连接MySQL报错:SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' (2)

    如下所示,PHP连接MySQL报错: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' ...

  4. Asp.Net连接Mysql报错Out of sync with server

    Asp.Net连接Mysql报错Out of sync with server 原因:程序引用的MySql.Data.dll版本高于服务器版本 解决:下载一个低版本的MySql.Data.dll,项目 ...

  5. Linux系统下启动MySQL报错:Neither host &#39;localhost.localdomain&#39; nor &#39;localhost&#39; could be looked up with

    Linux系统下启动MySQL报错:Neither host 'localhost.localdomain' nor 'localhost' could be looked up with 摘要 Li ...

  6. 启动Mysql报错:Another MySQL daemon already running with the same unix socket.

    启动Mysql报错: Another MySQL daemon already running with the same unix socket. 删除如下文件即可解决 /var/lib/mysql ...

  7. Mysql报错注入原理分析(count()、rand()、group by)

    Mysql报错注入原理分析(count().rand().group by) 0x00 疑问 一直在用mysql数据库报错注入方法,但为何会报错? 百度谷歌知乎了一番,发现大家都是把官网的结论发一下截 ...

  8. 解决:MySQL 报错:1045 - Access denied for user 'root'@'localhost'(using password YES)

    一.前言 今年疯狂迷上了开源,只要看到好的开源项目,就会不顾一切一股脑扎进去研究,五一期间发现一个很好的关于众筹的开源项目,但不巧,这个项目竟然是 PHP 写的,没学过 PHP,自然对这个开源项目毫无 ...

  9. 开启bin-log日志mysql报错:This function has none of DETERMINISTIC, NO SQL解决办法

    开启bin-log日志mysql报错:This function has none of DETERMINISTIC, NO SQL解决办法: 创建存储过程时 出错信息: ERROR 1418 (HY ...

  10. Navicat连接Mysql报错:Client does not support authentication protocol requested by server;

    Navicat连接Mysql报错:Client does not support authentication protocol requested by server: 刚安装Mysql,想用Nav ...

随机推荐

  1. Codeforces Global Round 17 - D. Not Quite Lee

    裴蜀定理 + lowbit Problem - D - Codeforces 题意 定义一个包含 \(m\) 个元素的数组 \(b\) 是好的,当且仅当满足以下两个条件 对于 \(b[i]\), 存在 ...

  2. 项目_1.3_手写SpringMVC框架

    初步修改项目 package com.hy.servlet; import java.io.IOException; import java.lang.reflect.InvocationTarget ...

  3. 帮你躲坑:pip install tensorflow 报错怎么办,import tensorflow 报错怎么办?

    补一补:什么是TensorFlow? 一句话介绍: Google 开源的基于数据流图的科学计算库,适合用于机器学习.深度学习等人工智能领域 百度百科的介绍: TensorFlow是谷歌基于DistBe ...

  4. ratel hook app

    目录 创建平头哥项目 创建一个基本的Android项目 手动创建一个平头哥项目(windows推荐) 通过模板的方式创建平头哥项目(windows不推荐) 插入第三方集成模块 RPC调用 RPC调用静 ...

  5. java统计一个文本文件英文单词

    package test;import java.io.*;import java.util.*;public class wordCount2 { public static void main(S ...

  6. Unity图集打包流程

    1.先打开图集打包工具 设置为Always Enables(Legacy Sprite Packer) 打开地址Edit - ProjectSetting-Editor--Sprite Packer ...

  7. redis数据类型常用方法

    一.String set:添加String类型数据 get:获取String类型数据 del:删除数据 append:在原基础上追加数据,假如原来k1值是v1,执行append k1 ddd,那么值就 ...

  8. Tomcat put 漏洞批量工具

    工具下载 https://share.weiyun.com/96ffd3bf26b09ffece8d01317f3b3efb

  9. Spark RDD编程

    1. 准备文本文件从文件创建RDD lines=sc.textFile()筛选出含某个单词的行 lines.filter()lambda 参数:条件表达式 2. 生成单词的列表从列表创建RDD wor ...

  10. ethcat开发记录 三

    一.关于controlword的控制 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 保留 待定 暂停 故障复位 模式有关 伺服使能 快停 上电 伺服准备好