This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes PreparedStatements and precompiled? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "PreparedStatements and precompiled?" Watch "PreparedStatements and precompiled?" New topic
Author

PreparedStatements and precompiled?

Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

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.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: PreparedStatements and precompiled?
 
Similar Threads
Hibernate cfg xml and Eclipse problem
problem with jboss can any one help?
Simple jdbc program error
javax.sql.RowSet, Oracle JDBC
JNDI exception when creating dataSource