• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get a blank ResultSet to do update?

 
Anna Kahn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I want to copy some row from one db to another, changing a few things in the process. So I thought using an updatable result to do this is the easiest. But I don't know how to get a blank ResultSet to do update.
Here is what I am thinking about doing:
...
Statement s = c.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
ResultSet r = s.execute ??? <-- what to do?
r.moveToInsertRow();
r.setObject(...); <-- copy from another ResultSet
r.insertRow();
 
zou xiao fei
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what DBMS are you using?
some big ones support "select...into..." query,you need not use so complex method.
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not a big fan of updatable resultsets. I believe that you should get in and get out as fast as possible to alleviate database resources.

Jamie
{
 
Anna Kahn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since I don't really care about the content of the row I am copying, I don't want to compose the INSERT INTO sql. Just have the source ResultSet and destination ResultSet and take the value from the src and set them into the destination and just insert. I am dealing with two database servers. And I need to modify a few of the column before inserting into the second server. So I don't think SELECT INTO can work.
So what is the simlest way using JDBC to copy rows from one db server to another, adjusting a few columns in the process, both servers have the same database schema?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic