wood burning stoves 2.0*
The moose likes JDBC and the fly likes JDBC statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC statements" Watch "JDBC statements" New topic
Author

JDBC statements

Shivaprakash Shettihalli
Greenhorn

Joined: Nov 20, 2007
Posts: 18
What the advantage of using Statement over Prepared Statement, not the reverse please
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Unlike a prepared statement, which has to be known ahead of time, a statement can take any string and try to execute it as a SQL statement. This is useful for programs that build SQL statement on the fly or that have to execute accept statements passed to it from other programs or components.

It should go without saying that this can be dangerous thing in certain environments (you originally asked this question in the servlets forum), if your code accepts SQL strings (or pieces of SQL Strings) from untrusted clients.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

Statements are usually faster than PreparedStatements if you cannot reuse PreparedStatements. If you can, it determines on the number of times the PreparedStatement can be reused.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC statements
 
Similar Threads
Instance Pooling in Servlets
Confirmation required
SecurityException: Prohibited package name
What is the Advantage Of Prepared Statement Over Statement
How to submit a null in radio button