Can anyone tell me wats happening here
Connection con =DriverManager.getConnection(\"connection_url\", \"username\", \"password\");
How connec
I mean con is a connection interface reference which can't point to an object of a class which implements connection interface
Wrong. It can and it must. The actual implementation class is provided by the JDBC driver vendor.
The DriverManager
keeps track of all JDBC Driver
s that have been loaded in your JVM (there are a couple of ways in which a Driver
can be loaded).
When you ask the DriverManager
to open a connection for you, it asks each of the loaded drivers whether it can handle the URL that you've specified.
If the Driver
can handle the URL, then it is asked to connect to the database using the supplied username and password. The Driver
supplies a connection object that implements the Connection
interface.
The DriverManager
really is just a small class that knows about each loaded Driver
and handles picking the right one. The implementation of Connection
(and Statement
, etc) is all handled by the Driver
.