• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

prepared statement

 
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does the databases identify the request is for prepared statement?
What is the process flow of handling prepared statement (starting from webserver to database server and back to webserver)?
I read from an article that prepared statements are using precompiled statement and after syntax check, compilation and optimization, handle is returned to the JDBC driver.
At the end of the program the statement handle is discarded.
I have not understood the complete process of handling prepared statement and the concept of handle. Can someone explain to me about this?
It would also be great if someone helps me to understand process going on at database when it receives the request for prepared statement, if possible with examples?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's really up to the JDBC driver how the implementation handles PreparedStatements. Remember that JDBC is just an API... Anyway, this is my "educated guess" at how things happen.
When you call prepareStatement("SELECT * FROM ..."), the driver or the database server itself compiles the SQL with wildcards into a proprietary query execution plan. The handle is simply an abstract reference to this already compiled execution plan. When you have set the parameters and call executeXXX(), the JDBC driver calls the pre-compiled query execution plan with the given parameters, thus, bypassing the sometimes costly query compilation phase.
I would like to hear others' takes on this, though.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You asked a similar question here.
Is there something else we can help you with?
Dave
reply
    Bookmark Topic Watch Topic
  • New Topic