没用插件,分页之类的,就直接用代码实现。。。
private int uploadDataType_1() throws SQLException{
//获取数据
ResultSet resultSet = DBConnection.executeQuery(
"SELECT * from TB_StoreHouse WHERE provice_id ='430000'"
);
//数据集结构
ResultSetMetaData reMetaData = resultSet.getMetaData();
System.out.println("数据集的结构---"+reMetaData);
//数据集的列数
int columnCount = reMetaData.getColumnCount();
System.out.println("数据集的列数---"+columnCount);
JSONArray array = new JSONArray();
int responseCode=0;
/*
* int a 分批上传 本批次数据的位数
*
* int b 为总共上传几批次
*/
int a = 0;
int b =0;
boolean result=true;
while ( result= resultSet.next()) {
//转json
JSONObject jsonObject = new JSONObject();
if (++a<200) {
for (int i = 1; i <= columnCount; i++) {
String columnLabel = reMetaData.getColumnLabel(i);
String value = resultSet.getString(columnLabel);
jsonObject.put(columnLabel, value);
}
array.add(jsonObject);
}else {
for (int i = 1; i <= columnCount; i++) {
String columnLabel = reMetaData.getColumnLabel(i);
String value = resultSet.getString(columnLabel);
jsonObject.put(columnLabel, value);
}
array.add(jsonObject);
//调用ws
GrainServiceImplService rs = new GrainServiceImplService();
GrainService re = rs.getGrainServiceImplPort();
responseCode =re.test(null, "1", 1, "3", "4");
System.out.println("上传第"+ ++b +"批数据,上传累计条数:"+b*200+"条");
a=0;
array= new JSONArray();
System.out.println("执行结果为 " + responseCode);
}
}
if (result) {
}else {
//调用ws
GrainServiceImplService rs = new GrainServiceImplService();
GrainService re = rs.getGrainServiceImplPort();
responseCode= re.test(null, "1", 1, "3", "4");
int c=a+(b*200);
System.out.println("本批次数据不满20条,共"+ c +"条");
System.out.println("整表数据传输完成");
System.out.println("执行结果为" + responseCode);
}
return responseCode;
}
老铁 十几几十G说的是机器内存 一般程序内存都只是1G、2G
你这代码太烂了 我给你改了下 还有你并没有把你查询的结果传给ws啊
最后分批上传的话 每一批用完马上把组装参数的list置成null,不要用这个list一直装参数,那样内存会爆,这样的话只要每批不超过内存,总数多大全ok
package util;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
public class TestCSDN {
private int uploadDataType_1() throws SQLException {
//获取数据
ResultSet resultSet = DBConnection.executeQuery(
"SELECT * from TB_StoreHouse WHERE provice_id ='430000'"
);
//数据集结构
ResultSetMetaData reMetaData = resultSet.getMetaData();
System.out.println("数据集的结构---"+reMetaData);
//数据集的列数
int columnCount = reMetaData.getColumnCount();
System.out.println("数据集的列数---"+columnCount);
JSONArray array = new JSONArray();
/*
* int a 分批上传 本批次数据的位数
*
* int b 为总共上传几批次
*/
int a = 0;
int b =0;
boolean result=true;
while ( result= resultSet.next()) {
//转json
JSONObject jsonObject = new JSONObject();
if (++a<200) {
for (int i = 1; i <= columnCount; i++) {
String columnLabel = reMetaData.getColumnLabel(i);
String value = resultSet.getString(columnLabel);
jsonObject.put(columnLabel, value);
}
array.add(jsonObject);
}else {
for (int i = 1; i <= columnCount; i++) {
String columnLabel = reMetaData.getColumnLabel(i);
String value = resultSet.getString(columnLabel);
jsonObject.put(columnLabel, value);
}
array.add(jsonObject);
//调用ws
System.out.println("上传第"+ ++b +"批数据,上传累计条数:"+b*200+"条");
toWS();
a=0;
array= new JSONArray();
}
}
if (result) {
}else {
//调用ws
System.out.println("本批次数据不满20条,共"+ a+(b*200) +"条");
toWS();
System.out.println("整表数据传输完成");
}
return responseCode;
}
private void toWS(){
GrainServiceImplService rs = new GrainServiceImplService();
GrainService re = rs.getGrainServiceImplPort();
System.out.println("执行结果为" + re.test(null, "1", 1, "3", "4"));
}
}
把你的http响应的超时设置长一些,否则可能会因为超时而客户端提前中断。内存一般不会超,现在的内存都是十几、几十 GB的。