mysql odbc executeBatch takes long time

550 views Asked by At

I'm writing back data of a table in Java to my MYSQl dB. But to execute one executeBatch it takes 1.241 s! Here my code:

updateLieferant = conn.prepareStatement(
    "UPDATE "+dbnames.artikel.name+" SET Abteilung = ? , statusAusmessen = ? , Status = ? " 
    +" WHERE " +dbnames.auftragsnummer +" = ? " +" AND " +dbnames.artikelnummer +" = ?");

updateLieferant.setString( 1, "blabla" );
updateLieferant.setString( 2, "blabla" );
updateLieferant.setString( 3, "blabla" );
updateLieferant.setString( 4, "blabla");
updateLieferant.setString( 5, "blabla" );

long time = System.nanoTime(); 
updateLieferant.executeBatch();
time = System.nanoTime()- time;

System.out.println(time/1000000);

outputs 1241 ms... is there anything I'm doing wrong? From this page I see that it should take around 100ms. http://rostislav-matl.blogspot.ch/2011/08/fast-inserts-to-postgresql-with-jdbc.html

1

There are 1 answers

5
NickJ On

executeBatch of for executing a statement a large number of times, as in the BPI section in the link you posted (it's in a loop), but here you are executing it only once.

Instead, try

updateLieferant.executeUpdate();