aspose file tools*
The moose likes JDBC and the fly likes Statement & PreparedStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Statement & PreparedStatement" Watch "Statement & PreparedStatement" New topic
Author

Statement & PreparedStatement

suman deb
Ranch Hand

Joined: Jul 14, 2005
Posts: 54
hi everybody...

under what situation we can't use PreparedStatement,but we have
to use Statement?
Sujith Kanaparthi
Ranch Hand

Joined: Sep 04, 2005
Posts: 45
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

Joined: Nov 15, 2000
Posts: 59
When you need to compile a SQL stored procedure, Statement would be used.


Aniruddha
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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 ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 293

The main (only? ) reason for using a Statement instead of a PreparedStatement is when the driver doesn't support PreparedStatements.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Statement & PreparedStatement