This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I would like to use the batching mechanismof JDBC 2.0 on preparedStatements. Can it be done? Sample code?.. PreparedStatement ps = conn.preparedStatement(sql); ps.setInt(1,35); ps.setInt(2,67); ps.addBatch(); <-------- Not sure where this goes
<a href="http://www.jobklub.com" target="_blank" rel="nofollow">http://www.jobklub.com</a><br /> 'Add Job To Life'
Steve Chernyak
Ranch Hand
Joined: Oct 19, 2000
Posts: 113
posted
0
What if you have different statements that need to be executed? For example: insert into parent (id, field) values (?, ?); insert into child (parent_id, anotherField) values (?, ?); I am able to get the batch to work with Statements, is there anyway to do this with PreparedSatements? Thanks
Lu Battist
Ranch Hand
Joined: Feb 17, 2003
Posts: 104
posted
0
It may work. I had something similar work on one driver but not the other, it may be the JDBC version they support. Anyway, try something like this:
[ July 11, 2003: Message edited by: Lu Battist ]
Steve Chernyak
Ranch Hand
Joined: Oct 19, 2000
Posts: 113
posted
0
I will have to do some performance testing to see if this is faster than using plain statements. I was hoping to send all of the sql to the database in one batch, but it might be faster to send multiple batches using PreparedStatements. I guess it will depend on wether it takes longer to send the data over the network or for the database to parse the sql. Thanks