• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get a blank ResultSet to do update?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what DBMS are you using?
some big ones support "select...into..." query,you need not use so complex method.
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic