让我根据接口文档的要求在数据库中抽取数据,然后调用webServer接口将数据上传。接口要求 数据在组织时,以json格式组织。就是byte[] jsonData。
我的把抽出来的数据转成json然后存jsonarray里了,现在怎么转成byte[]jsonData
求指教!!!!
private int uploadDataType_1() throws SQLException{
//获取数据
int start = 1;//开始记录索引位置
int pageSize = 20;//页大小(每页显示条数即一次查询多少条数据)
int SJpageSize =20 ;//实际当前页的数据量
int responseCode=0;//初始化返回值
int n = 0;//测试
int m =0;
while (SJpageSize==20) {
String sql = "select * from (select *, ROW_NUMBER() OVER(Order by id ) AS RowId from TB_StoreHouse ) as b where RowId between "+ start +" and "+ pageSize ;
ResultSet resultSet = DBConnection.executeQuery(sql);
start+=20;
pageSize+=20;
//数据集结构
ResultSetMetaData reMetaData = resultSet.getMetaData();
//数据集的列数
int columnCount = reMetaData.getColumnCount();
JSONArray array = new JSONArray();
SJpageSize=0;
while ( resultSet.next()) {
//转json
JSONObject jsonObject = new JSONObject();
for (int i = 1; i <= columnCount; i++) {
String columnLabel = reMetaData.getColumnLabel(i);
String value = resultSet.getString(columnLabel);
jsonObject.put(columnLabel, value);
}
++SJpageSize;
array.add(jsonObject);
}
System.out.println(array);
GrainServiceImplService rs = new GrainServiceImplService();
GrainService re = rs.getGrainServiceImplPort();
responseCode=re.test(array, "1", 1, "3", "4");
m +=SJpageSize;
System.out.println("当前第"+ ++n+"页,有"+SJpageSize+"条,已上传"+m+"条");
}
return responseCode;
responseCode=re.test(array, "1", 1, "3", "4"); --报错要求第一个参数是byte[]jsonData