如何将结果集保存在 ArrayList 中,在同一单元格中保存不同的行?

How save resultset in an ArrayList saving different row in the same cell?

pstpr = con.prepareStatement("select id_prodotto from prodotto_autore where id_autore='" + id.getInt(1) + "';");
            prodotti = pstpr.executeQuery();
            while (prodotti.next()) {
                pstcoa = con.prepareStatement("SELECT id_autore FROM prodotto_autore  WHERE id_prodotto='" + prodotti.getString(1) + "';");
                coautori = pstcoa.executeQuery();
                List<String> row =null;
                while (coautori.next()) {
                     row = new ArrayList<>(); // new list per row
                     row.add(coautori.getString(1));

                    //prodott.add(coalizione.getString(2));
                }
                coaliz.add(row);
            }

我可以根据第一个结果集的结果计算第二个结果集的结果。现在我想将这个结果保存在一个数组列表中,但在同一个单元格中。我的意思是我有的是

[[2], [79], [2], [2], [2], [2], [2]]

但我需要的是

[[2, 79], [2], [2], [2, 2, 2]]

我该怎么办?谢谢

    pstpr = con.prepareStatement("select id_prodotto from prodotto_autore where id_autore='" + id.getInt(1) + "';");
        prodotti = pstpr.executeQuery();
        while (prodotti.next()) {
            pstcoa = con.prepareStatement("SELECT id_autore FROM prodotto_autore  WHERE id_prodotto='" + prodotti.getString(1) + "';");
            coautori = pstcoa.executeQuery();
            List<String> row =null;
            row = new ArrayList<>();
            while (coautori.next()) {
                  // new list per row
                 row.add(coautori.getString(1));

                //prodott.add(coalizione.getString(2));
            }
            coaliz.add(row);
        }

您正在尝试在第二个结果集中创建一个新的数组列表。而是在第二个结果集之外和第一个结果集中创建它。