在Sqoop往mysql导出数据的时候报了这个错误,一开始还以为是jar包没有打进去或者打错位置了,未解便上网查询。

Error reading from database: java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@27ce24aa is still active. No statements may be issued when any streaming result sets are open and in use on a given connection. Ensure that you have called .close() on any active streaming result sets before attempting more queries.
java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@27ce24aa is still active. No statements may be issued when any streaming result sets are open and in use on a given connection. Ensure that you have called .close() on any active streaming result sets before attempting more queries.

1.通过百度寻找此问题的解决方式,找到了如下答案:

由于mysql-connector-java的bug造成的,出错时我用的是mysql-connector-java-5.1.12-bin.jar,更新成mysql-connector-java-5.1.32-bin.jar就可以了。

但是我通过wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.32.tar.gz,下载了tar.gz包 解压之后得到mysql-connector-java-5.1.32-bin.jar

注意mysql-connector-java-5.1.32-bin.jar,看见没有是-bin.jar,maven项目的pom.xml中添加mysql依赖,会产出mysql-connector-java-5.1.32.jar 没有-bin,注意这是两个不同的包。

千万不要直接从项目中拷过来。。。最后替换掉sqoop目录原有jar包,我的目录是/opt/software/sqoop/lib/

但是!!!并没有解决这个问题。。。

2. 科学上网

老大看我焦头烂额却没有丝毫进展,告知我要科学上网,这种问题要到墙外查阅资料。我也知道,但是最近vpn好笑来月经了似的翻不出去了。。。

大哥最后出马,在StackOverFlow上找到了答案:

Try including the option --driver com.mysql.jdbc.Driver in the import command.

Worked for me...Thanks Man

sqoop export \
--connect $STAT_JDBC_CONNECT \
--username $JDBC_USERNAME \
--password $JDBC_PASSWORD \
--table $TABLE \
--update-mode allowinsert \
--driver com.mysql.jdbc.Driver \
--export-dir $SQOOP_HDFS_RESULT_DAY \
--columns stat_ds,command,answer,counts

3.解决这个问题,便深知科学上网的重要性,便开始研究vpn为何失效翻不过去长城?

我用的工具ShadowSocks,找了半天没有类似的经验,就把电脑关机。重启之后在没有改任何配置的前提下就好了!

4.SparkSql中使用round内置函数完成四舍五入保留两位小数

  /**
* 统计音箱型号分布情况
*
* @param dataFrame
* @return
*/
def echoModelDistributeStat(dataFrame: DataFrame, preDay: String): List[String] = {
var numdf = dataFrame.groupBy("model").agg(count("model").as("model_count"))
// 统计出总共的设备数
var sumdf = numdf.groupBy().agg(sum("model_count"))
// 计算设备型号的总数量
var modelSum = sumdf.collect()(0)(0)
// 计算出需要的的DF
var modelInfo = numdf.select(numdf("model"), numdf("model_count"), (numdf("model_count") / modelSum * 100).as("model_percent"))
modelInfo.registerTempTable("m")
// 将日期转换为时间戳
val timeStamp = TimeUtils.getTimeStamp(preDay + " " + Constant.TIME_ZERO)
val timeDf = modelInfo.sqlContext.sql("select " + timeStamp + " as stat_ds,m.model,m.model_count,round(m.model_percent,2) as model_percent from m")
// 将DF转成List[Row]的形式
val list = timeDf.collect().toList
// 将List[Row]转为List[String]
val listStr = listRowConvertListStr(list)
return listStr
}

  

java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@27ce24aa is still active. No statements may be issued when any streaming result sets are open and in use on a given connection的更多相关文章

  1. java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default

    error: java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default at ja ...

  2. java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/

    出现这个异常原因可能很多: 1.编码问题 2.没有加载类驱动:换一种数据库的连接方式,就忘了这个:Class.forName(driverclass); import java.io.IOExcept ...

  3. Spark on Yarn:java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost\\db_instance_name:1433;databaseName=db_name

    本文只是针对当前特定环境下,出现的问题找不到sqljdbc驱动的案例.具体出现原因,可能是spark版本问题,也可能是集群配置问题. yarn-client方式下: 通过--jars参数指定驱动文件位 ...

  4. Oracle java.sql.SQLException: 数字溢出

    六月 30, 2016 5:47:47 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinit ...

  5. mybatis 执行查询时报错 【Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: 】

    org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLE ...

  6. 吴裕雄--天生自然 JAVA开发学习:解决java.sql.SQLException: The server time zone value报错

    这个异常是时区的错误,因此只你需要设置为你当前系统时区即可,解决方案如下: import java.sql.Connection ; import java.sql.DriverManager ; i ...

  7. java.sql.SQLException: 关闭的连接 解决办法

    程序如果长时间不进行数据库操作,那么数据源中的 Connection 很可能已经断开.其原因有可能是防火墙,或者连接的数据库设置的超时时间.这里使用的是 C3P0 连接 oracle 数据库,引起的异 ...

  8. mybatis项目报错:java.sql.SQLException: ORA-00911: 无效字符 解决方法

    如果你用java写程序访问数据库,出现这个问题:java.sql.SQLException: ORA-00911: 无效字符 at oracle.jdbc.driver.DatabaseError.t ...

  9. java中mysql查询报错java.sql.SQLException: Before start of result set

    异常:java.sql.SQLException: Before start of result set 解决方法:使用rs.getString();前一定要加上rs.next(); sm = con ...

随机推荐

  1. PHPExcel IE导出乱码问题

    引用改网站介绍:http://blog.chinaunix.net/uid-22414998-id-113450.html PHPExcel是微软认证的一个PHP操作Excel表格的类库,功能强大,所 ...

  2. 【MongoDB】嵌套数组查询方案

    From:http://stackoverflow.com/questions/12629692/querying-an-array-of-arrays-in-mongodb 数据 db.multiA ...

  3. angularJs多文件上传

    <input type="file" id="file{{$index}}" class="file{{$index}}" ngf-s ...

  4. 打印出现:You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:

    解决办法: 第一种:Product -> Target -> Capabilities -> Background Modes -> 勾选Remote notification ...

  5. Docker(1)在CentOS上的安装与卸载

     一. Docker的安装 CentOS7 上安装: 1. 卸载旧版本 $ sudo yum remove docker \ docker-client \ docker-client-latest ...

  6. Linux命令之乐--curl

    参数: -I   获取头部信息 -s/--silent      Silent mode. Don't output anything 沉默模式 --connect-timeout <secon ...

  7. MySQL的system命令在渗透测试中的使用以及UDF提权

    声明:下面引用关于SYSTEM的东西是自己之前的内容,是自己没有研究透导致的错误结论:有了错就要改,做技术的不能弄虚作假,时时刻刻要求自己要谨慎,虽然我的博客没人看,但是也要向所有已经看到的人道歉,错 ...

  8. javascript 禁止页面选取-兼容IE、Chrome和firefox浏览器

    在做到一个页面需要禁止网页内容被选取的时候,碰到浏览器兼容的问题,解决方法如下 1.单独使用适用于IE.Chrome浏览器,主要是在head的<script>标签里面加上如下代码 docu ...

  9. onbeforeunload 适用DOM 0级,不适用 DOM 2级

    你可以在控制台试下: window.addEventListener("beforeunload", function () { return 'ss'; }); 我这里 chro ...

  10. 第一个MapReduce的例子

    第一个MapReduce的例子 Hadoop Guide的第一个MapReduce的例子是处理气象数据的(数据来源ncdc),终于跑通了.总结一下步骤,安装hadoop不在本文中介绍 1 数据预处理 ...