Statement | PreparedStatement |
---|---|
A standard Statement is used to create a Java representation of a literal SQL statement and execute it on the database. | A PreparedStatement is a precompiled statement. This means that when the PreparedStatement is executed, the RDBMS can just run the PreparedStatement SQL statement without having to compile it first. |
Statement has to verify its metadata against the database every time. | While a prepared statement has to verify its metadata against the database only once. |
If you want to execute the SQL statement once go for STATEMENT | If you want to execute a single SQL statement multiple number of times, then go for PREPAREDSTATEMENT. PreparedStatement objects can be reused with passing different values to the queries |
Search
Useful Links
Tuesday, June 18, 2013
What is the difference between a Statement and a PreparedStatement?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment