title: Copy from Oracle to SQLite in Java
body: <p>I was asked to implement a code to copy some info from a Oracle DB to an SQLite DB. I got the ResultSet from Oracle and start inserting in SQLite, but it seems to me that is really slow. Is there a better way or can you suggest a better way to achieve this?</p>
  
  <p>My code looks like follows:</p>
  
  <pre><code>    OracleDB oracleDB = new OracleDB();
      SQLiteDB sqliteDB = new SQLiteDB();
  
  
      oracleConnection = oracleDB.connect();
      sqliteConnection = sqliteDB.connect();
      {
          Statement s = null;
          PreparedStatement ps = null;
          try {
              s = sqliteConnection.createStatement();
              s.executeUpdate("CREATE TABLE IF NOT EXISTS test_table (field1, field2)");
  
              ps = oracleConnection.prepareStatement("SELECT * FROM temp_desarrollo");
              ResultSet rs = ps.executeQuery();
  
              while (rs.next()) {
                  ps = sqliteConnection.prepareStatement("INSERT INTO test_table VALUES (?, ?)");
                  //SET PARAMETERS
                  ps.setString(1, rs.getString(1));
                  ps.setString(2, rs.getString(2));
                  ps.executeUpdate();
              }
  
          } catch (SQLException ex) {
              Logger.getLogger(OracleToSQLite.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
      oracleDB.disconnect(oracleConnection);
      sqliteDB.disconnect(sqliteConnection);
  </code></pre>