Geeks Talk

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.

Statement v/s PreparedStatement

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?...

Go Back   Geeks Talk > Software Development > Java
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Java Java related Issues and Problems

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-18-2009
Contributing Member
 
Join Date: Aug 2009
Location: Indore
Posts: 33
Thanks: 9
Thanked 5 Times in 5 Posts
Sarje is on a distinguished road
Statement v/s PreparedStatement

PreparedStatement is called pre compiled statement but Statement is not why?
How PreparedStatement is pre compiled?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-24-2009
Contributing Member
 
Join Date: Aug 2009
Location: bangalore
Posts: 30
Thanks: 11
Thanked 3 Times in 3 Posts
abhi981 is on a distinguished road
Talking Re: Statement v/s PreparedStatement

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
Reply With Quote
The Following User Says Thank You to abhi981 For This Useful Post:
  #3 (permalink)  
Old 10-05-2009
Junior Member
 
Join Date: Jun 2008
Location: Indore
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
simranfxbytes is on a distinguished road
Re: Statement v/s PreparedStatement

Mean no need to compile every time.
Reply With Quote
Reply

  Geeks Talk > Software Development > Java

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 08:22 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved