• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt about PreparedStatement and Statement

 
gopal kishan
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I know the difference between PreparedStatement and Statement.

1)But i want to know, if PreparedStatment is a precompiled query,what it mean??

2) when it compiles and where it store a compiled query??

3) How Statement object compiles??

please clarify...........


thanks in advance
Gopal
[ August 05, 2005: Message edited by: Bear Bibeault ]
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, you don't really need to know how it happens. It just does. It's definitely faster, for the most part, especially if you're going to run the same query many times. Also, PreparedStatements are safer. You don't have to worry about the "'" character when building up an OQL string if you're binding in query parameters.
 
Makarand Parab
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gopal
As you know PreparedStatements are subclass of Statements. It means PreparedStatement does something special, that is when you execute a PreparedStatement for the first time, the query string gets executed, during which a execuation plan is made for that query and maintained for all the further calls for the same query at db level, where for Statement when the query IS FIRED, each time a new execution plan is created.
Creation of this plan is a heavy process looking at number of user hitting the website.
As u can see this makes PreparedStatement much faster than the Statements. Morever u have the flexibility of passing the parameters to the PreparedStatement.

Hope this answers your query.
Let me know

If i am wrong, please correct me.

Regards
Makarand Parab
 
gopal kishan
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI All,

Thanks for your reply...

The explanation is very clear.

once again Thanks

regards
Gopal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic