blogger templates blogger widgets
This is part of a list of blog posts.
To browse the contents go to

JDBC API - Getting Started

JDBC API - What, how and why

JDBC API defines interfaces and classes for writing database applications in Java by making database connections.

This API standardizes :
1. The way to establish the connection to the database
2. Approach to initiate queries
3. The data structure of query result

JDBC classes are located in java.sql package.

Let's look into the package and see what it says. The key to understanding any API documentation is knowing where to start.

Driver API

  • this is an interface that every driver class must implement.
  • DBMS drivers released by dbms vendors implement this interface.
  • A Driver class is loaded, by creating an instance of itself. Class.forName("foo.bah.myDriver")
  • DriverManager doesn't stop you from loading multiple drivers but when it receives a connection request, it will ask each driver in turn to try to connect to the target URL (connection urls are explained later). The Driver that succeeds handles the connection request.
  • Have a look at Driver API Documentation here


DriverManager API

  • The DriverManager provides a basic service for managing a set of JDBC drivers.
  • When getConnection() is called the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application.
  • Note that when we do Class.forName("foo.bah.myDriver") the JVM uses the same classloader used by the program to load the Driver class.
  • Have a look at DriverManager API Documentation here

Continue reading: JDBC Driver and Driver Types

No comments:

Post a Comment