I have a message and many recipients, what I want to know is when I want to save it.. is it good to use Statement.execute() for each recipient that the message have or it could be considered like "hard-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.