aspose file tools
The moose likes JDBC and the fly likes Jdbc q Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Jdbc q" Watch "Jdbc q" New topic
Author

Jdbc q

NileshJ Njadhav
Greenhorn

Joined: Jan 18, 2011
Posts: 3
Difference between statement and prepare statement?
Mohamed Sanaulla
Bartender

Joined: Sep 08, 2007
Posts: 2927
    
  15

NileshJ Njadhav wrote:Difference between statement and prepare statement?

Statement and PreparedStatement.


Mohamed Sanaulla | My Blog
NileshJ Njadhav
Greenhorn

Joined: Jan 18, 2011
Posts: 3
thanks
Martin Vajsar
Bartender

Joined: Aug 22, 2010
Posts: 2329
    
    2

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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Jdbc q
 
Similar Threads
Instance Pooling in Servlets
How to submit a null in radio button
Confirmation required
What is the Advantage Of Prepared Statement Over Statement
SecurityException: Prohibited package name