title: Best way when using prepared statement in nested loop
body: <p>When executing multiple queries in nested loops what is the best way? I have a code like follows: </p>
  
  <pre><code>String sql1 = SQLContainer.SOME_SQL;
  String sql2 = SQLContainer.SOME_SQL2;
      if (someThings != null) {
          for (Some some : someThings) {
              ps = con.prepareStatement(sql1);
              ps.setString(1, some.name);
              ps.setString(2, some.type);
              ps.executeUpdate();
  
              if (some.getParams != null) {
                  for (Some2 some2 : some.params) {
                      ps = con.prepareStatement(sql2);
                      ps.setString(1, some2.name);
                      ps.setString(2, some2.value);
                      ps.setString(3, some2.type);
                      ps.executeUpdate();
                  }
              }
          }
      }
  </code></pre>
  
  <ol>
  <li>Is it ok to use like that?</li>
  <li>Should I make 2 diferent loop, one for sql1 and one for sql2?</li>
  <li>Should I create 2 different methods for different loops?</li>
  <li>Or what should i do?</li>
  </ol>
  
  <p>The sqls are just insert statements and two sqls are somehow related with each other. I dont want to insert somes when i get error from some.params too.</p>