Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

performance

 
joew weakers
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have a series of simple SQL insert statements that I need to execute based on values extracted from a for loop, is it quicker to use PreparedStatements or not. This is what my code looks like at present. Thnaks a lot, Joe.

...
Statement stmt = sc.conn.createStatement();
for(int f = 0; f < features.length; f++)
{
insert_query = "insert into joeweaker.interest_area_features values(\n"+
Welcome.userID+","+Welcome.sessionID+","+area_id+",'"+features[f]+"')";
stmt.execute(insert_query);
}
...
stmt.close();
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a thread discussing this
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!