For Programmers: Free Programming Magazines  


Home > Archive > Java Help > February 2006 > ResultSet Object ? I Thought you can't instantiate an Interface. - What's going on ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ResultSet Object ? I Thought you can't instantiate an Interface. - What's going on ?
Hal Rosser

2006-02-24, 3:57 am

When working with JDBC, we create a ResultSet object with
"statement.executeQuery(strQuery)" as shown in the API.
BUT- How is this so ? I was taught that you cannot instantiate an Interface.
(Is there a different type that implements the interface being instantiated
? I could't find a quick explanation in the API, or in the Sun JDBC
tutorial.

Thanks
Hal


Hal Rosser

2006-02-24, 7:01 pm

>
> The key for you to understand is the following:
> (*) You do *not* know the names of the DB-specific classes,
> or how these classes are implemented internally.
> (*) You do *not* *need* to know all that. That is solely
> the business of the DB vendor.
> (*) All you need to know, is the API doc of the interfaces
> in package java.sql


Thanks


Greg R. Broderick

2006-02-24, 7:01 pm

"Hal Rosser" <hmrosser@bellsouth.net> wrote in
news:BNvLf.6742$Pv1.2819@bignews6.bellsouth.net:

> When working with JDBC, we create a ResultSet object with
> "statement.executeQuery(strQuery)" as shown in the API.
> BUT- How is this so ? I was taught that you cannot instantiate an
> Interface. (Is there a different type that implements the interface
> being instantiated ? I could't find a quick explanation in the API,
> or in the Sun JDBC tutorial.


There is a different, database-specific class that implements
ResultSet. For instance, if you're using the Oracle thin JDBC driver,
this would be the oracle.jdbc.OracleResultSet class. If you're using
DB2 (and the DB2 JDBC drivers), then this class would be different. If
you're using MySQL (and the MySQL JDBC drivers) then this class would
be different yet again.

The java.sql.ResultSet interface provides a common interface that is
implemented by each of these vendor-specific JDBC drivers. This allows
you to write one set of code and have it (if you're careful with your
SQL dialect) run unmodified on several different database platforms.

Cheers
GRB


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com