| Author |
statement Vs prepared statement for ordinary select queries
|
sumitha sudhakar
Greenhorn
Joined: Aug 09, 2010
Posts: 21
|
|
|
Which is better for simple select queries statement or prepared statement?
|
 |
Sridhar Santhanakrishnan
Ranch Hand
Joined: Mar 20, 2007
Posts: 317
|
|
I think Statement can be used for one-time call, say to get the user details.
PreparedStatement is pre-compiled, so it can be used for queries which are repeatedly executed with different parameters.
Besides, unlike Statement, there is no chance of SQL injection with PreparedStatement.
|
 |
sumitha sudhakar
Greenhorn
Joined: Aug 09, 2010
Posts: 21
|
|
Thanks for the response.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26193
|
|
|
I always use a PreparedStatement. Almost all queries have a parameter in them and I want the security benefits. And the few queries that don't have a parameter are run multiple times.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: statement Vs prepared statement for ordinary select queries
|
|
|