• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Statement

 
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !!
 
Greenhorn
Posts: 9
Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can instantiate interfaces when they are implemented as classes.
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Enkita mody wrote: . . . could you attach any doc if you know.thanks

Start here.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Winston, i was reading your post but you have deleted.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic