Best way to copy table from one database to any other database
843859Apr 1 2007 — edited May 24 2007I need to write an application to perform database table copy from one kind of database to another kind of database.
I just wrote a simple JDBC program which essentially does the something like below:
PreparedStatement statement = null;
ResultSet rs = null;
try
{
System.out.println("insertSQL:" + insertSQL.toString());
statement = target.prepareStatement(insertSQL.toString());
System.out.println("selectSQL:" + selectSQL.toString());
rs = source.executeQuery(selectSQL.toString());
int rows = 0;
while (rs.next())
{
rows++;
for (int i = 1; i <= columns.size(); i++)
{
statement.setString(i, rs.getString(i));
}
statement.execute();
}
System.out.println("Copied " + rows + " rows.");
But problem with this one is that it takes lot of time( more than 60 mins) for 100k records transfer. Would there be any faster way to do this?
TIA...