• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

PreparedStatement slows down

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I try to insert many rows (up to 5000) with ca. 40 Columns into MS
Access over the driver sun.jdbc.odbc.JdbcOdbcDriver. Autocommit is
false.
So to have a better performace I tried to use a PreparedStatement:

PreparedStatement prepUpdate =
m_dbAccess.getConnection().prepareStatement("INSERT INTO
tb_Clients_History VALUES(?,?...)");

while(...)
{
prepUpdate.setString(1,"data0");
....
prepUpdate.setString(40,"data40"));

prepUpdate.executeUpdate();
}
prepUpdate.close();
m_dbAccess.getConnection().commit();

This solution is very slow. So I tried to use prepUpdate.addBatch() but
this came circa to the same result. Then I tried only to see how many
time it will take, a hard INSERT INTO with all data in my loop and that
worked 10 TIMES faster!!!
How that? What I do wron in my preparedStatement?

Regards
 
Message for you sir! I think it is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic