This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC and the fly likes Updateable ResultSet just for doing inserts: good idea? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Updateable ResultSet just for doing inserts: good idea?" Watch "Updateable ResultSet just for doing inserts: good idea?" New topic
Author

Updateable ResultSet just for doing inserts: good idea?

Jesper Ottosson
Ranch Hand

Joined: Mar 21, 2000
Posts: 51
I hate it when my INSERT statements become horribly long. One thing that would solve this is querying for an empty updateable resultset from the table i want to insert into, and then use the update methods to specify the values (after doing a moveToInsertRow)
Is this a good idea, or does it have serious performance implications?
/ Jesper
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

I find that PreparedStatements clean up a long insert statement:

instead of

I'm not a big fan of scrollable/updateable resultsets, but you could query your table for an empty ResultSet:
"select * from emp where 1=2"...then move to insert row...etc
but I'm not sure if you can have a where clause on the resultset if you want to insert into it(some drivers/DB's throw exceptions)

Jamie
 
Don't get me started about those stupid light bulbs.
 
subject: Updateable ResultSet just for doing inserts: good idea?