Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jdbc q

 
NileshJ Njadhav
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difference between statement and prepare statement?
 
Mohamed Sanaulla
Saloon Keeper
Pie
Posts: 3159
33
Google App Engine Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NileshJ Njadhav wrote:Difference between statement and prepare statement?

Statement and PreparedStatement.
 
NileshJ Njadhav
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Martin Vajsar
Sheriff
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes people test the speed of a Statement vs. PreparedStatement and notice that if the Statement is executed only a handful of times, it is slightly faster, so they conclude the Statement is the way to go if you execute it less than, say, 10 times in your application. This is, of course, not a good idea because of SQL injection anyway, but even the performance perspective is wrong. If the application is actually used by many (say, 100) users and each user invokes the 10-statement functionality, the DB gets hit by these Statements thousand times, not ten times. Which means the load on the DB is much higher and the PrepareStatement would clearly win performance-wise.

I haven't ever seen a Statement/PreparedStatement performance comparison which would mention it, so I thought I'd point it out here.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic