This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "JDBC statements" Watch "JDBC statements" New topic

JDBC statements

Shivaprakash Shettihalli

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

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

Joined: Oct 27, 2005
Posts: 20077

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.

How To Ask Questions How To Answer Questions
Have you checked out Aspose?
subject: JDBC statements
It's not a secret anymore!