I am building a reporting tool and I need to execute queries on remote databases and store the result set in my own database (because I do not have write permission on remot
You probably have the ResultSet based on an execution of a select query.Now instead of getting the ResultSet and then iterating through it to create the table, we can also execute a single query for table creation.
Your original query:
select * from table_name
Instead of executing this and iterating, execute this
create table new_table_name as (select * from table_name)