• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Statement & PreparedStatement

 
suman deb
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody...

under what situation we can't use PreparedStatement,but we have
to use Statement?
 
Sujith Kanaparthi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suman,

When u want to exceute the same query in loop then the best one to use is PreparedStatement as it will be precompiled.
I would like you to go through this thread to have better clarificationPrepearedStatement Vs Statement

Regards
Sujith
 
Aniruddha Mukhopadhyay
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you need to compile a SQL stored procedure, Statement would be used.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Aniruddha Mukhopadhyay:
When you need to compile a SQL stored procedure, Statement would be used.


Its unlikely you would compile a Stored Procedure from Java code, this will probably be done when the procedure is created. If you need to call a Stored Procedure from Java, you would use a CallableStatement.
[ September 28, 2005: Message edited by: Paul Sturrock ]
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main (only? ) reason for using a Statement instead of a PreparedStatement is when the driver doesn't support PreparedStatements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic