File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Statement v/s PreparedStatement
Joined: Sep 17, 2009
Sep 23, 2009 02:27:10
is called pre compiled statement but Statement is not why?
is pre compiled?
M K Rayapudi
Joined: Feb 19, 2007
Sep 23, 2009 03:36:52
In case of
, the skeleton of an SQL statement is prepared/compiled during it's creation/instantiation.
PreparedStatement ps = con.prepareStatement ("insert into EmpTable values(?,?,?)");
place holders (? marks) are used instead of actual values, this skeleton is compiled before going to execute with the actual values, as follows:
ps.setString(1,"1001"); ps.setString(2,"Abhijit"); ps.setString(3,"B.Tech"); ps.executeUpdate(); // here, the SQL statement doesn't require any comiplation, becuase its already compiled before
In case of
, no SQL statement is prepared/compiled during creation/instantiation.
Later, the SQL statement with values together executed as follows:
st.executeUpdate("insert into EmpTable values('1001','Abhijit','B.Tech')");
I agree. Here's the link:
subject: Statement v/s PreparedStatement
Tell me the main difference between Statement and PreparedStatement?
statement Vs prepared statement for ordinary select queries
Diff b/w Statement and PreparedStatement
pre-compile and prepared statement
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014