GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Statement" Watch "Statement" New topic
Author

Statement

Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Overview of Prepared Statements

Sometimes it is more convenient to use a PreparedStatement object for sending SQL statements to the database. This special type of statement is derived from the more general class, Statement, that you already know.

Source:http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html

I don't understand what does it mean ?

PreparedStatement and Statement both are interface not class !!


OCA7
Amruta Mistry
Greenhorn

Joined: Jan 25, 2012
Posts: 9

PreparedStatement is an interface while Statement is a class
If you refer JDBC API you will get more idea about same.


Thank You
Amruta Mistry
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Amruta Mistry wrote:PreparedStatement is an interface while Statement is a class
If you refer JDBC API you will get more idea about same.


If it would have been then why do i ask here ?.See this http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39053
    
  23
You can instantiate interfaces when they are implemented as classes.
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Campbell Ritchie wrote:You can instantiate interfaces when they are implemented as classes.


Never seen such, could you attach any doc if you know.thanks
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7892
    
  21

Enkita mody wrote:If it would have been then why do i ask here ?.See this http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html

Enkita, there is no point in asking vague questions and then getting snippy with someone who's trying to help you. Amruta is absolutely right; it IS explained in the JDBC API (which comprises a lot more than just one class) AND in the JDBC tutorials.

Please ShowSomeEffort and SearchFirst (←click). Nobody here is simply going to spoon-feed you an answer; and if they do, the chances are it will be deleted.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Winston Gutkowski wrote:
Enkita mody wrote:If it would have been then why do i ask here ?.See this http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html

Enkita, there is no point in asking vague questions and then getting snippy with someone who's trying to help you. Amruta is absolutely right; it IS explained in the JDBC API (which comprises a lot more than just one class) AND in the JDBC tutorials.

Please ShowSomeEffort and SearchFirst (←click). Nobody here is simply going to spoon-feed you an answer; and if they do, the chances are it will be deleted.

Winston


He said Statement is class so i gave him link that API is showing that interface not class.Do you think i did wrong ? i apologize if i did.thanks for your help
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7892
    
  21

Enkita mody wrote:He said Statement is class so i gave him link that API is showing that interface not class.Do you think i did wrong ? i apologize if i did.thanks for your help

OK, fair enough. But I suggest that next time you BeNice and point out the error.

The fact is that JDBC implementations are supplied by 3rd parties - generally the company that produced the database - so the likelihood is that MANY things you use in such a framework will be interfaces.

However, I'm still not quite sure what your question is: If you want to know why you would use a PreparedStatement, then you really do need to read the JDBC tutorials thoroughly.

Winston
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Winston Gutkowski wrote:
Enkita mody wrote:He said Statement is class so i gave him link that API is showing that interface not class.Do you think i did wrong ? i apologize if i did.thanks for your help

OK, fair enough. But I suggest that next time you BeNice and point out the error.

The fact is that JDBC implementations are supplied by 3rd parties - generally the company that produced the database - so the likelihood is that MOST things you use in such a framework will be interfaces.

Winston


I was nice i don't know why do you think i was not nice in that post.Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39053
    
  23
Enkita mody wrote: . . . could you attach any doc if you know.thanks
Start here.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14193
    
  20

Enkita mody wrote:I don't understand what does it mean ?

PreparedStatement and Statement both are interface not class !!

It could be that this is just a mistake in the tutorial. Don't expect everything to be perfect and without errors - the Oracle tutorials and documentation have been written by people who can make mistakes, just like everybody else.

This particular mistake doesn't make the whole tutorial incomprehensible.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Jesper de Jong wrote:
Enkita mody wrote:I don't understand what does it mean ?

PreparedStatement and Statement both are interface not class !!

It could be that this is just a mistake in the tutorial. Don't expect everything to be perfect and without errors - the Oracle tutorials and documentation have been written by people who can make mistakes, just like everybody else.

This particular mistake doesn't make the whole tutorial incomprehensible.


Thanks, i was looking for this answer to clear my doubt.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Jesper de Jong wrote:
Enkita mody wrote:I don't understand what does it mean ?

PreparedStatement and Statement both are interface not class !!

It could be that this is just a mistake in the tutorial. Don't expect everything to be perfect and without errors - the Oracle tutorials and documentation have been written by people who can make mistakes, just like everybody else.


But since the PreparedStatement interface does actually extend the Statement interface, that suggests to me that the tutorial is correct in the important detail and that the word "class" in the originally-quoted sentence is a minor error.
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Supplying Values for PreparedStatement Parameters

You must supply values in place of the question mark placeholders (if there are any) before you can execute a PreparedStatement object. Do this by calling one of the setter methods defined in the PreparedStatement class.


Weird terminology, but now i have been familiar with it.
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

@Winston, i was reading your post but you have deleted.
 
GeeCON Prague 2014
 
subject: Statement