• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PreparedStatement slows down

 
michael byrd
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic