数据库结果集转json格式但是没办法打印出来,是什么情况?

图片说明

数据库中task表的数据如上图

运行结果如下图
图片说明

public static void main(String args[]) throws SQLException{

            getConnection();
            DB db = new DB();
            rs = db.getRs("select * from task");
            JSONArray jsonArray = db.formatRsToJsonArray(rs);
            System.out
                    .println("1111");
    }
```各位大神  这是我的主函数片段







下面贴上getRs和formatRsToJsonARRAY方法


```public ResultSet getRs(String sql){   //获取数据查询结果
      Connection dbConnection = this.getConnection();
      try {
          ppst = dbConnection.prepareStatement(sql);
          rs = ppst.executeQuery();
          while(rs.next()){
              int i=1;
              rs.getObject(i);
              i++;
          }
      } catch (SQLException e) {
          System.out.println("查询出错:"+e.getMessage());
      }

      return rs;
  }

public static JSONArray formatRsToJsonArray(ResultSet rs) throws SQLException{
      java.sql.ResultSetMetaData md = rs.getMetaData();  //获取数据库表结构
      int num = md.getColumnCount();//得到总行数
      JSONArray array = new JSONArray();// json数组,根据下标找值;[{name1:wp},{name2:{name3:'ww'}}]name为key值,wp为value值
      while(rs.next()){
          JSONObject mapOfColValues = new JSONObject();
          for(int i=1;i<=num;i++){
              mapOfColValues.put(md.getColumnName(i), rs.getObject(i));//添加键值对
              System.out
                    .println(mapOfColValues.toString());
          }
          array.add(mapOfColValues);
      }
      return array;

  }

为什么触发了formatRsToJsonArray方法时,方法中的打印json中的数据
System.out
.println(mapOfColValues.toString());

这一行没有打印出来呢?

System.out.println(mapOfColValues.toString());
没有打印出来,打断点看看,是不是数据库没有查询道数据呢?
看样子最终的 JSON 数组是空的。