Originally posted by marilyn murphy:
Check out java.sql Interface Connection:
DriverManager.getConnection( "jdbc:mysql://urlToDatabase" );
returns a Connection object which can be any object that implements the interface Connection. We don't know which Connection object is returned by the vendor's implementation of this method. We don't [b]need to know in order to use it. Each vendor creates their own implementation using the methods defined in the Connection interface. So all you need to do is fill in the String which is given to you by the vendor and the method works. If you change from mysql to MS SQL server, all you need to do is change the string and the method still works fine, even though the implementation of the methods defined by Connection by the new vendor may be (and probably are) completely different. Polymorphism at its best.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton