Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updateable ResultSet just for doing inserts: good idea?

 
Jesper Ottosson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic