If Resultset is an interface, then how can we call methods like next() etc. without defining the method body anywhere in the program. As per concept in an interface, methods are only declared but not defined. And also some implementer class is required to implement that interface.
How Resultset interface is working?
Collapse
X
-
Tags: None
-
Yes, database driver providers have already implemented that interface and they return you that concrete implementation when you ask for a Resultset from the prepared statement.
Your code doesn't need to know the actual class that implemented the interface so you can just develop against the interface methods. This allows you to use the same code even if you change databases because your code didn't depend on specific implementations .
Coding to the interface is very powerful like that because it allows you to write code that works with classes that haven't been created yet as long as they adhere to the interface contract.
Comment