| Author |
doubt about PreparedStatement and Statement
|
gopal kishan
Ranch Hand
Joined: Feb 23, 2005
Posts: 99
|
|
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
Joined: Feb 20, 2001
Posts: 580
|
|
|
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.
|
James Carman, President<br />Carman Consulting, Inc.
|
 |
Makarand Parab
Ranch Hand
Joined: Dec 10, 2004
Posts: 121
|
|
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
Joined: Feb 23, 2005
Posts: 99
|
|
HI All, Thanks for your reply... The explanation is very clear. once again Thanks regards Gopal
|
 |
 |
|
|
subject: doubt about PreparedStatement and Statement
|
|
|