• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PreparedStatements and precompiled?

 
Brij Garg
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


Prepared Statements aren't actually compiled, but they are bound by the JDBC driver


What we mean by "bound by the JDBC driver"?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means that some (not all) JDBC drivers will bind your parameter to the appropriate table column early/upfront and keep that binding (so it's not repeated each time the prepared statement is executed). It's a performance enhancement basically.
 
Brij Garg
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

Is binding and precompiling are one and same thing or they have different meaning?
If they are different then how?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They have different meanings, in fact one is used within the other (for PreparedStatements).

Precompiling is a step that involves preparing the SQL statement for execution on the Database server, you often want to do this if the SQL is going to be executed more than once. Binding forms part (but not all) of that precompilation step.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic