Tuesday, January 29, 2008 04:06 PM
When you Load the Class "sun.jdbc.odbc.JdbcOdbcDriver" you are loading a "concrete" instance of a JDBC driver into memory.
The "DriverManager" class is a "Factory" design pattern. When you pass it the parameter "jdbc:odbc" you are telling the Driver manager to find a class that fits those parameters. The DriverManager will then, find the "concrete class" create an instance of it... make the connection and pass you back a concrete instance of that connections.
The beautiful thing about Interfaces is that If the concrete class implements the methods that are described by the interface correctly, then you can call those methods using the call those methods based on the interface alone.
If you have no concrete class returned from the DriverManager, then you are out of luck.... and if you try to execute the methods, then you will get a "null pointer" exception.
Hope this helps.