title: Inserting multiple rows into database table using JAVA
body: <p>I need to insert multiple rows (about 1 mln.) containing random numbers into a Postgresql database. This code generates one row with random numbers into a database. How can i make the statement loop itself for any amount of times?</p>
  
  <pre><code>        Random rand = new Random();
          for (int j=0;j &lt; 1;j++);
  
              stmt = c.createStatement();
              String sql = "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) "
                      + "VALUES ('" + rand.nextInt() + "', '" + rand.nextInt() + "', '" + rand.nextInt() + "', '" + rand.nextInt() + "'," +
                      " '" + rand.nextInt() + "')";
              stmt.executeUpdate(sql);
  
          stmt.close();
          c.commit();
          c.close();
  </code></pre>