Noways, i have encountered a problem about mysql and ResultSet.
the Exception Trace:
java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@7834eb 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.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:930)
at com.mysql.jdbc.MysqlIO.checkForOutstandingStreamingData(MysqlIO.java:2646)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1861)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1846)
By default, ResultSets are completely retrieved and stored in memory. In most cases this is the most efficient way to operate, and due to the design of the MySQL network protocol is easier to implement. If you are working with ResultSets that have a large number of rows or large values, and can not allocate heap space in your JVM for the memory required, you can tell the driver to stream the results back one row at a time.
To enable this functionality, you need to create a Statement instance in the following manner:
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);
The combination of a forward-only, read-only result set, with a fetch size of
Integer.MIN_VALUE
serves as a signal to the driver to stream result sets row-by-row. After this any result sets created with the statement will be retrieved row-by-row.
There are some caveats with this approach. You will have to read all of the rows in the result set (or close it) before you can issue any other queries on the connection, or an exception will be thrown.
Reference:
http://bugs.mysql.com/bug.php?id=39156
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-implementation-notes.html
No statements may be issued when any streaming result sets are open and in use on a given connection
Noways, i have encountered a problem about mysql and ResultSet.the Exception Trace:java.sql.SQLException: Streaming result set com.mysql
1) ERROR 1222 (21000): The
use
d SELECT
statement
s have a different number of columns : 这是因为使用union的两个SQL语句产生的记录的表结构不一致. 必须是结构完全一致的记录集合才可以使用UNION. 以上就是两个表的字段不一样,导致,所以大家可以检查下。
您可能感兴趣的文章:在ASP.NET 2.0中操作数据之六十九:处理Computed Columns列DevExpress GridControl实现根据RowIndex和VisibleColumns
Vadim I. Utkin (作者)
高清电子版
The book is devoted to systems with discontinuous control. The study of discontinuous dynamic systems is a multifacet problem which embraces mathematical, control theoretic and application aspects. Times and again, this problem has been approached by mathematicians, physicists and engineers, each profession treating it from its own positions. Interestingly, the
result
s obtained by specialists in different disciplines have almost always had a significant effect upon the development of the control theory. It suffices to mention works on the theory of oscillations of discontinuous nonlinear systems, mathematical studies in ordinary differential equations with discontinuous righthand parts or variational problems in nonclassic
statement
s. The unremitting interest to discontinuous control systems enhanced by their effective application to solution of problems most diverse in their physical nature and functional purpose is, in the author's opinion, a cogent argument in favour of the importance of this area of studies. It seems a
use
ful effort to consider, from a control theoretic viewpoint, the mathematical and application aspects of the theory of discontinuous dynamic systems and determine their place within the scope of the present-day control theory. The first attempt was made by the author in 1975-1976 in his course on "The Theory of Discontinuous Dynamic Systems" and "The Theory of Variable Structure Systems" read to post-graduates at the University of Illinois, USA, and then presented in 1978-1979 at the seminars held in the Laboratory of Systems with Discontinous Control at the Institute of Control Sciences in Moscow.
执行SQL报错:The
use
d SELECT
statement
s have a different number of columns
以上翻译:使用的SELECT语句具有不同数量的列
原因:我们在 SQL 语句中使用了 UNION 连接两张表时,查询字段数量不一致导致
# 效果展示:
我们需要将数据展示如上图所示
# 错误案例:
SELECT
a.quantity AS in_quantity,
a.price AS in_price,
(a.quantity * a.price) AS in_amount,
0 AS out_quantity,
0 AS out_price
Sqoop import命令报错 No
statement
s may be
issued
when any
streaming
result
set
s are
open
and in
use
on a
given
connection
. Ensure that you have called .close() on any active
streaming
result
set
s before attempting more queries.
1.原命令: sqoop import --connect jd
ERROR manager.SqlManager: Error reading from database: java.sql.SQL
Exception
:
Streaming
result
set
com.
mysql
.jdbc.RowDataDynamic@1d5a7f6 is still active. No
statement
s may be
issued
when any strea
[root@master bin]# ./sqoop import --connect jdbc:
mysql
://192.168.10.169/qyyx_test --
use
rname root --
password sendinfo --table spread_log --hbase-create-ta
ERROR
Streaming
result
set
com.
mysql
.jdbc.RowDataDynamic@1d5a7f6 is still active. No
statement
s may
[jifeng@jifeng02 sqoop]$ bin/sqoop import --connect jdbc:
mysql
://10.X.X.X:3306/lir --
use
rname dss --password 123123 --table bb_month --hive-import -m 100
Warning: /home/jifeng/sqoop/../hcatalog does n
上一篇博客中我们分析了两种
MySQL
client避免内存溢出的方法和各自优劣,并分析了cursor方式的实现原理,文章最后根据测试和比较质疑了文档中对
stream
result
set
的描述。
这篇我们来深入聊聊
stream
result
set
的实现原理和应用实践。
stream
result
set
的实现方式
MySQL
官方文档中没有说明,这里我们只有自食其力阅读源码了。
Warning: /opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/bin/../lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please
set
$ACCUMULO_HOME to the root of your Accumulo installation.