In JDBC, I see that Connection
is an interface, which defines methods for interacting with Database.
I also know that interface contains only abstract m
The whole point of defining abstract classes (or interfaces) is to have subclasses of the abstract class (or classes implementing the interface), providing an implementation for all the abstract methods of the abstract class (or of the interface). Otherwise, an abstract class or interface could never be used, and would be completely pointless.
So, what DriverManager.getConnection does, in fact, is the following:
return new MySqlConnection();
or
return new OracleConnection();
depending on the URL (this is an oversimplified explanation. In reality, it's a bit more complex than that).
and MySQLConnection and OracleConnection are concrete classes implementing the Connection interface:
public class MySQLConnection implements Connection {
...
}