Hi Java Pals, Can any explain exactly, how PreparedStatemet Works? Any how excatly it makes difference in preformace compared to its base class Statement Class?
I request people to explain the internal aspects of working, I found only its syntax and usage on sites but no where i found its internal working. It will be helpful to all, if you give citation to refer.
Maximilian Xavier Stocker
Joined: Sep 20, 2005
This question cannot really be answered because it depends on the driver.
There are essentially two ways in which it works.
One: The driver parses your query and identifies parameters. When you set the parameters the driver stores them and when you execute the driver builds the query from it's parsed bits and the bound parameters.
Two : The driver sends the query to the database where it is parsed (and perhaps a query plan is compiled) and a handle of some sort is returned to the driver. The driver then passes along the setXXX method calls and execute calls to the database directly.
And there can of course be variations of either. Like I said it depends on the database and driver. If this does not satisfy you then you can consult the source for one of the open source drivers like Jtds or the MySQL driver.