title: One preparedstatement for multiple tables Java
body: <p>1) Can I use one prepared statement to pass data to multiple tables from java? where I am using JDBC driver.</p>
  
  <pre><code>try
          {
              conn = ac.getConnection();
              String insert = "INSERT INTO PPN_WORKFLOW(C2_F_Date,C2_Completed) VALUES(?,?)";
              stmt = conn.prepareStatement(insert);
              stmt.setDate(1, date);//question 2
              stmt.setInt(2, 1);
              stmt.executeUpdate();
              stmt.close();
              String insert2 = "INSERT INTO CREATE_ERF(Purc_Part_New_F_Date,Purc_Part_New_Completed) "
                      + "VALUES(?,?)";
              stmt = conn.prepareStatement(insert2);
              stmt.setDate(1, date);
              stmt.setInt(2,1);
              stmt.executeUpdate();
          }
          catch(SQLException | ClassNotFoundException e) {e.printStackTrace();}
          finally
          {
              if(stmt != null) {
                  stmt.close();
              }
  
              if(conn != null) {
                  conn.close();
              }
          }
  </code></pre>
  
  <p>Here I am using stmt(PreparedStatement) for table PPN_WORKFLOW and CREATE_ERF?</p>
  
  <p>2) the PPN_WORKFLOW table consists of more paremeters like</p>
  
  <pre><code>PPN_WORKFLOW(C1_S_Date,C2_F_Date,C2_Completed)
  </code></pre>
  
  <p>but I would like to update 2 and 3 parameter, So Is my code is correct.</p>