posted 10 years ago
Connection, PreparedStatement, and ResultSet are all interfaces in the java.sql package. That same code (using interfaces) can work with any one of dozens of databases, and the only thing I have to change is the connection parameters passed to getConnection() in the first line. Each vendor provides their own implementation of those interfaces. I don't know or care anything about the names of the implementation classes or about how they do their jobs. All that matters to me is they meet the contracts set out by the interfaces. That is, the ResultSet implementation will have an executeQuery() method and a next() method.
Another canonical example is the Collections Framework in java.util. I can code to a List without caring whether it's an ArrayList or LinkedList or CopyOnWriteArrayList or whatever. Depending on what I'm doing, I may even be able to code to Collection, without even caring if it's a List or Set or something else.