title: How to copy table from one database to another?
body: <p>I need to take a table from one database and upload it to a different database.
  So, I create two separate connection . Here is my code  </p>
  
  <pre><code>Connection connection1 = // set up connection to dbms1
  Statement statement = connection1.createStatement();
  ResultSet result = statement.executeQuery("select * from ............. "); 
  
  Connection connection2 =  // set up connection to dbms2
  // Now I want to upload the ResultSet result into the second database
  Statement statement2 = connection2.createStatement("insert into table2 " + result);
  statement2.executeUpdate();
  </code></pre>
  
  <p>The above last lines do not work 
  How can i do this ? The bottomline is <strong>how to reuse a ready resultset</strong></p>
  
  <p>ResultSet is a ready java object . I hope there is a way add it to batch or something like this and <code>executeUpdate</code> , <em>but not to write the result set to some temporary space (<code>List</code>, <code>csv</code> etc.) and the insert</em></p>