I found from lots of resources that JDBC is a typical example of Bridge design pattern. But they usually didn't tell the details, so I would like to know the details. According to my understanding:
Driverinterface is the bridge between theDriverManagerand the concrete JDBC driver classesConnectioninterface is the bridge between theDriverand the concrete JDBC connection classesStatementinterface is the bridge between theConnectionand the concrete SQL statement classesResultSetinterface is the bridge between theStatementand the concete result set classes
Please modify if the my statements are wrong. Also I guess DataSource interface is also a bridge, but I can not figure out that is a bridge between which classes
The Bridge pattern, as defined by the "Gang of Four", means decoupling an abstraction from its implementation so that the two can vary independently. In this context, it's not so much about bridging different classes together. Instead, the pattern illustrates the Open/Closed principle where the interface (JDBC API) stays the same, but new implementations (JDBC drivers) can be added and substituted for each other.
What this means is that data access code using JDBC only needs to depend on the API interfaces such as
Connection,StatementorResultSet, instead of caring about the actual database system the application is connected to. JDBC will bridge the application to the database that's used in the environment the application is deployed to. For this reason, you can run the same code (using JDBC abstractions) against different RDBMS, and only the JDBC driver (implementation) needs to change.Added by RUI: http://www.informit.com/articles/article.aspx?p=29302