Convert Resultset to String array

前端 未结 5 921
死守一世寂寞
死守一世寂寞 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:43

    you do not need arr = em.split("\n"); since you are looping through each row (assuming that 1 row = 1 email address ) you just need this :

            ArrayList arr = new ArrayList();
            while (rs.next()) {
               arr.add(rs.getString("EM_ID"));
               System.out.println(arr.get(arr.size()-1));
            }
    

提交回复
热议问题