Saturday, March 3, 2018

JDBC Connection

The early version of JDBC provided a Driver class with a GetConnection method for application.  Underneath Driver uses Java Socket class to get a connection to the database.  Later, DriverManager class provide the connection using an url.  Using a generic interface saved the application the need to know which specific driver to use.  The connection returned is a physical connection (a socket) which is adequate for a 2-tier client-server architecture as each client will create and use its own connection and seldom sharable.

JDBC v2.0 uses DataSource to support Java Transaction API and a 3-tier architecture.  An intermediate layer (application server) sits between client and the database.  DataSource returns a logical connection from a connection pool which improves performance by avoiding set up time for every JDBC connection request.