why executeQuery method not available in Connection Class

2356 views java
-4

why executeQuery() method not available in Connection Class? So if it is available we can easily call executeQuery method using Connection Object.So can't we extend the Statement Class to Connection Class and achieve this.

answered question

Are you asking why the executeQuery is in the Statement class and not in the Connection class??

yes sir........

1 Answer

10

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 doesn't decide/know how to execute the query (batch, template...)

posted this

Have an answer?

JD

Please login first before posting an answer.