File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes who is implementing ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "who is implementing ResultSet" Watch "who is implementing ResultSet" New topic
Author

who is implementing ResultSet

Srinivasa Rao
Greenhorn

Joined: May 30, 2002
Posts: 2
ResultSet is an interface, you have to implement the interface if u want to provide any implementaton to the methods, actually we are not implementing this interface,but calling the methods like next(), afterLast() etc. in our class. how it is possible.
Thanks in advance.
Srinivasa Rao
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You register a driver using Class.forName(...) (actually, that line allows the driver to register itself), then when you call DriverManager.getConnection(...), the DriverManager looks at the drivers it knows about and returns one that will handle the given database URL.
Everything from this point is done via interfaces. There are concrete classes behind these interfaces, but it is better to treat them as 'generic database classes' rather than the specific types because this makes your code independant of the specific database.
If you want to know what the actual class is, check System.out.println( rs.getClass().getName() );
DO NOT cast to this specific class! This ways leads to the dark-side of the Java
Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
The implementer of your JDBC classes (eg com.sybase.jdbc2.jdbc or sun.jdbc.odbc) implements ResultSet. The advantage of keeping the methods in the interface is that it frees the developer from being tied down to any specific implementation.


Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
Srinivasa Rao
Greenhorn

Joined: May 30, 2002
Posts: 2
Thanks david and snigdha
i got the answer now.
Srinivasa Rao
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: who is implementing ResultSet
 
Similar Threads
abstract
how the session bean and remote interface are communicated without implementing in definition
clonable interface
Methods in Interface
How i can use JAXB to convert a ResultSet to XML document?