It's not a secret anymore!*
The moose likes JDBC and the fly likes How Does PreparedStatement Work internally 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 "How Does PreparedStatement Work internally" Watch "How Does PreparedStatement Work internally" New topic
Author

How Does PreparedStatement Work internally

vikram hegde
Greenhorn

Joined: Sep 07, 2005
Posts: 18
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.

Thanks,
Vikram
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How Does PreparedStatement Work internally
 
Similar Threads
How to get method parameter names
J2EE Tutorial - Converter
Difference between Component and Class
Is ArrayList an AbstractClass?
SUGGEST: Making our own hibernate?