Convert Resultset to String array

前端 未结 5 946
死守一世寂寞
死守一世寂寞 2021-01-05 03:16

I need to Convert My result set to an array of Strings. I am reading Email addresses from the database and I need to be able to send them like:

message.addRe         


        
5条回答
  •  时光取名叫无心
    2021-01-05 03:57

    to get the desired output:

    replace these lines

    String[] arr = null;
    while (rs.next()) {
        String em = rs.getString("EM_ID");
        arr = em.split("\n");
        for (int i =0; i < arr.length; i++){
            System.out.println(arr[i]);
        }
    }
    

    by

    String arr = null;
    while (rs.next()) {
        String em = rs.getString("EM_ID");
        arr = em.replace("\n", ",");
        System.out.println(arr);
    }
    

提交回复
热议问题