aspose file tools*
The moose likes JDBC and the fly likes How to get a blank ResultSet to do update? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to get a blank ResultSet to do update?" Watch "How to get a blank ResultSet to do update?" New topic
Author

How to get a blank ResultSet to do update?

Anna Kahn
Greenhorn

Joined: Oct 29, 2001
Posts: 2
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

Joined: Oct 26, 2001
Posts: 9
what DBMS are you using?
some big ones support "select...into..." query,you need not use so complex method.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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

Joined: Oct 29, 2001
Posts: 2
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get a blank ResultSet to do update?