In JDBC getConnection is a static method which returns object of Connection Interface? The getConnection method is defined in DriverManager class as a blank body as follows:
@CallerSensitive
public static Connection getConnection(String url, String user, String password) throws SQLException {
// compiled code
}
I am not getting how it is working? What happens when we return an object to interface? How Connection interface using this object?
How it is using this object for statment in the below line:
Statement s= c.createStatement();
Again how things are working internally in above line?
I want a deeper explanation basically how interface and classes work together to things like this. I know what an interface is, how it is implemented by the classes. It is used to support multiple inheritance and to provide security. But how are these concepts related in this example?