Why executeQuery()
method isn't available in Connection
Class?
If it was available we can easily call executeQuery
method using Connection
Object.
So can't we extend the Statement
Class to Connection
Class to achieve this?
It break the Single responsibility principle
principle that states that every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class.
Connection class handle connection and doesn't decide/know how to execute the query (single, batch, template...)