Perfomance for multiple inserts  
Author Message
X_AWemner_X





PostPosted: 2003-7-4 23:11:00 Top

java-programmer, Perfomance for multiple inserts > Statement stmt = con.createStatement();
> stmt.addBatch("insert into table_name1 ...");
> stmt.addBatch("insert into table_name2 ...");
> stmt.addBatch("update table_name3 ...");
> stmt.addBatch("update table_name4 ...");
> stmt.addBatch("delete from table_name5 ...");
> stmt.executeBatch();
>
> And that is a good idea because the critical part of operations
> like this is the Statement-object. That has the direct connection
> with the SQL-server-side. And now you are able to execute a lot
> of statements with only 1 Statement-object, this looks like
> an sql-batch-script.

And if you (original author) going to benchmark, you could try concatenating
insert queries into a one large sql formula. Then you just run it and let
dbserver do the job.
StringBuffer sBuffer = new StringBuffer();
sBuffer.append("Insert Into ....;");
sBuffer.append("Insert Into ....;")
sBuffer.append("Insert Into ....;");
stmt = connection.createStatement(sBuffer.toString());
stmt.execute();