I have a message and many recipients that I want to know when I want to save it. Is it good to use Statement.execute () for each recipient that has a message, or can it be considered "difficult" -coding "
public void save(Int id,String subject, String body, ArrayList<String> emails){
String sq = "CALL saveMessage(?,?)";
CallableStatement st = this.connection.prepareCall(sq);
st.setInt(1,id);
st.setString(2, subject);
st.setString(3, body);
st.execute();
for(String e:emails){
query = "CALL saveRecipientByMessage(?,?)";
CallableStatement st2 = this.connection.prepareCall(query);
st2.setInt(1,id);
st2.setString(2,e);
st2.execute();
}
}
Thanks for reading.
source
share