I am using the Interface Connection from the package java.sql
Actually I though it a Class but when I tried to look at the source code I figured out that it is an Interface.
In the source of the Connection interface there are only single line for each method without any implementation!!
What makes this interface works as it?
Database to connect to: MySql
Connection source code page:
http://www.docjar.com/html/api/java/sql/Connection.java.html
It is not the interface that “works” but one of its implementations, which is specific to your particular RDBMS vendor. In fact, it is typically the vendor who provides the implementation of the
Connectioninterface.When you call
driver manager searches through registered JDBC drivers, finds the one for MySQL (it knows it’s MySQL from the connection string), passes connection properties to the constructor of the class inside MySQL JDBC driver that implements
Connection, and returns the resultantConnectioninstance back to you. For example, the driver may return an instance of a package-private classMySqlConnectionthat implementsConnection, and your program would use it to interact with RDBMS without knowing any details about the class, other than the fact that it implementsConnection.