• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Statement vs. Prepared Statement

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to know the clear difference between the use of statement and prepared statement. In case of prepared statement, the object is created first time in the memory of database and can be used for all later invocation. If that is true, in all our web application, we should use prepared statement always, since multiple users will be accessing the website and the same object of that prepared statement can be used multiple times. My doubt is that, what is the purpose of having normal statement then? Another confusion, when at the end of method we close the prepared statement, does the object get closed from the memory of the database as well or only gets closed from the server?
Appreciate your detailed input on this.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, you should read this article.
Second, you don't have to worry about any "objects" being "closed" in the database. What the use of PreparedStatement does in the database is basically caching; the database engine compiles the SQL skeleton into a query plan and caches the resulting "executable". It's up to the database server whether it wants to keep the compiled stuff in memory after the statements have been executed and committed.
 
get schwifty. tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic