my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes Query on Connection interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Query on Connection interface" Watch "Query on Connection interface" New topic

Query on Connection interface

vijay saradhi

Joined: Sep 23, 2004
Posts: 1
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

Joined: Mar 18, 2004
Posts: 128

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 / 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.
I agree. Here's the link:
subject: Query on Connection interface
It's not a secret anymore!