By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,806 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,806 IT Pros & Developers. It's quick & easy.

How Resultset interface is working?

bsadhukhan
P: 4
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.
Feb 27 '12 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
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.
Feb 27 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.