• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface or Class?

 
Rajarsi Ghosh
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am new to java. I learnt previously that we can not instantiate an interface. We need to first implement it then we can create an object of it. But in JDBC how are we using the following interfaces without implementing them:
1. PreparedStatement
2. CallableStatement
3. Statement
4. ResultSet
because in the documentation that i am getting these are referred as interfaces.
Thanks in advance

Rajarsi
[ May 23, 2006: Message edited by: Bear Bibeault ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you don't implement those interfaces, but the JDBC driver sure does. Note that there is no constructor for these anywhere - what you get back from the various JDBC methods are objects that implement those interfaces.

Simplifying quite a bit, you could say that that is what a JDBC driver is: an implementation of the various JDBC interfaces.
[ May 23, 2006: Message edited by: Ulf Dittmer ]
 
stu derby
Ranch Hand
Posts: 333
 
Rakhi Patra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rajarsi Ghosh:
Hi

I am new to java. I learnt previously that we can not instantiate an interface. We need to first implement it then we can create an object of it. But in JDBC how are we using the following interfaces without implementing them:
1. PreparedStatement
2. CallableStatement
3. Statement
4. ResultSet
because in the documentation that i am getting these are referred as interfaces.
Thanks in advance

Rajarsi

[ May 23, 2006: Message edited by: Bear Bibeault ]
 
Rakhi Patra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U r right
1. PreparedStatement
2. CallableStatement
3. Statement
4. ResultSet
these all are interface But we r not implementing those.The implementation lies under the thirdparty vendor provided database driver.Such as
for ResultSet it is the interface lies in java.sql.ResultSet and its
the that implement these interface is com.mysql.jdbc.ResultSet for mysql
database,for oracle something different ,like this for all different database
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To find of class of the object

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic