Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Statement

 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !!
 
Amruta Mistry
Greenhorn
Posts: 9
Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PreparedStatement is an interface while Statement is a class
If you refer JDBC API you will get more idea about same.
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can instantiate interfaces when they are implemented as classes.
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10243
58
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10243
58
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enkita mody wrote: . . . could you attach any doc if you know.thanks
Start here.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20962
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Winston, i was reading your post but you have deleted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic