Getting info from resultset
I am copying records from source DB to target DB using two resultsets.
Both resultsets were created based on a the same select query, but the target resultset is opened in CONCUR_UPDATABLE (and is empty).
I loop on the records of the source resultset and for each record I loop on the columns and update each columns in the target resultset.
My problem is that I need to output all the inserts that are done backstage to the target DB to a file. Is there any way to get the inserts from the resultset somehow or from the connection?
Is there any way to audit the DB changes done by my program?
Thanks in advance.
[649 byte] By [
naamawa] at [2007-11-26 16:13:58]

# 1
So, working backwards to what I think was your original question, every time a record is inserted into database A, you want to copy that record to database B?
That's called "replication". Many databases support replication, or at least work with products that do replication. Use those features or products rather than trying to hack together your own product in Java.
# 2
I also think that the solution of your problem will be in the database and not in java.
If your database supports stored procedures it is best to create one to handle the data copy. However if it is unavoidable to use java I would use an SQL statement like:
INSERT INTO table2 SELECT * FROM table1;
To answer the second one. If your database supports triggers you can use one to store information in a table (for example, store the user, IP address and timestamp every time a row is added to a table)