Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two PreparedStatement Object with Same Query

 
velmurugan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Every one knows that PreparedStatement is prepared once, and the precompiled version of the query is stored in the Database. (That means SQL syntax parsing done only once at the time of preparation)

If i am creating two different PreparedStstement object with the same query.

Is the second object uses the precompiled query (created by the first one) Or Both query will be parsed by the SQL parser and created a two precompiled version of query in the Database.


Please help me
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'typically' the same query will only be compiled once, but the exact behaviour is dependent on the database. I understand Oracle matches the query String, so you should ensure they are the same.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"velmurugan",
Please check your private messages.
-DOM
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, and it is also the case that a database can discard these precompiled queries to save room, so even exact matches can be compiled in the DB multiple times. I have never worried about it too much though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic