Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Statement v/s PreparedStatement within the Java forums, part of the Software Development category; PreparedStatement is called pre compiled statement but Statement is not why? How PreparedStatement is pre compiled?...
|
|||||||
|
|||
|
Hi Sirje,
In case of PreparedStatement, the skeleton of an SQL statement is prepared/compiled during it's creation/instantiation. For e.g. 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,"Sirje"); ps.setString(3,"B.Tech"); ps.executeUpdate(); // here, the SQL statement doesn't require any comiplation, becuase its already compiled before But in case of Statement, no SQL statement is prepared/compiled during creation/instantiation. For e.g Statement st=con.createStatement(); Later, the SQL statement with values together executed as follows: st.executeUpdate("insert into EmpTable values('1001','Sirje','B.Tech')"); I hope I tried to cleare the concept. Thanks & Regards, Abhijit |
| The Following User Says Thank You to abhi981 For This Useful Post: | ||
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can Select statement be used along with Update statement? | pankit | SQL | 6 | 01-15-2009 07:19 AM |
| Automating an SQL Statement | GregF | LoadRunner | 5 | 09-02-2008 02:15 PM |
| Update statement for OWB | ddlg_1280 | Oracle | 0 | 04-21-2008 03:37 AM |
| Why we have to close connection, statement, prepared statement | Geek_Guest | Java | 8 | 02-27-2008 07:09 AM |
| Evaluate SQL statement | Geek_Guest | Oracle | 1 | 09-30-2007 07:04 AM |