简体   繁体   中英

mysql odbc executeBatch takes long time

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

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM