• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface in JDBC (Interview Question)

 
Doshi Milan
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,
I am confused that in JDBC , Connection, Statement, ResultSet etc are all Interfaces.
We all know that interfaces have ALL methods incomplete and the one who is implementing those interfaces should complete those methods.
Then how are we able to use :
Con.createStatement();
Stmt.executeQuery(Qry1);
Rs.next();
Where Con, Stmt and Rs are references of Connection, Statement and ResultSet respectively.
Who is implementing and completing these methods?
Thanks in advance.
Regards,
Milan Doshi.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The provider of the JDBC driver is responsible for providing the methods that implement these interfaces. Different DBMS will implement them differently.
regarding
Con.createStatement();
where con is a Connection object
createStatement() method of the connection object creates an object that implements the statement interface.
The JDBC API has a better explanation.

Bosun
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic