Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query on Connection interface

 
vijay saradhi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While writing database programs we use interfaces such as Connection, Statement etc.
But our class does not implement these interfaces.
Why is it so???
For example:
class xyz
{
Connection con = DriverManger.getConnection();
Statement stmt = con.createStatement()
.....
}
Here our class does not implement Connection as well as Statement interfaces

It will be very helpfull if someone gives us the reasons.
Thanks in advance.
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see is that, you dont implement the sql interfaces is that you get a Default Implementation from the Vendor who owns the Database to which you are coding for, or the Default implementation if using ODBC Data Sources.

Simply because there is not standard as to how a Database Application provides a non SQL interface to other Systems / Languages...so sun has atleast Standardized the interface that a java Programmer has to program to, to access the Database so that your code remains Database independent.

you could still implement the connection Class, but then that would mean you will be implementing the whole set of interfaces as all the interfaces are hirarchically linked...(that is, you get a Statement Object from a connection Object, a ResultSet Object from a Statement etc). You should be knowing The database you are intending to write the driver inside out, because it also involves calling native methods on the Database Side.

Hope this is attempting to answer your point.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic