The core to fulfill this flexibility was that the library needed to provide some form of mapping between the vendor−specific code and the abstract representation needed by the user−land code. Taking a lead from the then−emerging design patterns craze, a global driver−manager system was established (designers call this a Factory pattern). This pattern allows a driver to be registered with the system without having to know or import the libraries for a specific implementation. For example, a text string representing the name of the driver class file is good enough to describe the driver to use.
Once the driver name was established, it was then a simple matter to ask the global manager for a connection to "the database" and receive an abstract representation of the connection. Once you have the connection representation, all the rest of the classes that your user code deals with are also abstract without your knowing the real implementation classes.
Different driver types
Realizing that at the time not all developers, or even database vendors, were sold on the Java language, the specification enabled the vendors to provide different types of drivers. These could range from 100% pure Java to a thin wrapper over an existing library, or, in the case of ODBC, a bridge to a completely different database−interface API altogether.
As the factory concept gained greater popularity, it was possible to provide different levels of drivers even for the same database product. Users could choose which one they preferred for the given application, and even 114
Chapter 7: Using JDBC to Interact with SQL Databases among different implementations for the same database from third−party sources. For example, if the Java code is running on the same machine as the database, a thin wrapper over the native shared memory libraries is much faster than the 100% Pure Java version that uses sockets. Yet if the applications are on separate machines, a shared memory driver will not work, and so network−aware drivers are more appropriate.
Standard APIs for driver implementers
An important factor in getting the database vendors to sign up was the internal API used to provide a consistent interface. The JDBC team did a lot of the hard work, ensuring that the top−level behavior would remain consistent so long as the minimal requirements of the internal API scheme were maintained.
This public API meant that all forms of third−party writers could build their own drivers if they wished. As a result, it helped speed the adoption of Java as hackers everywhere went to town creating drivers for every database known to man. No longer were they required to wait for the vendor to release the next version of its product in another 12 months' time when they could build it themselves and put it within a standard API for everyone to use.
Since then almost all important APIs, and in particular the enterprise APIs, have included this dual level of public APIs available to be implemented. The infrastructure has become known as the Service Provider Interface (SPI). If you look through the Javadoc for the J2EE libraries, you will notice that they all have a .spi package or packages. These are the internal, public interfaces that a driver manager must implement.
New Feature With the release of J2EE 1.3, the APIs are now starting to move away from the service−provider model. The Java Connector Architecture, which promises an even more abstract way of defining and locating driver implementations for the various APIs, is starting to take its place. Don't expect this to change the system overnight, but it is a big move within the enterprise space.
Getting Started
Using JDBC requires a little bit of setup. The first and most important step is to decide whether your application is going to be a simple, standalone application or a more complex one requiring the enterprise features. JDBC exists on two levels — a simple level, which is derived from the original JDBC code, and an enterprise−capable level, which encompasses all of the newest capabilities added in JDBC.



 

 

 

 

 

 

 

 

 

 

 

 

   
 
  JDBC interface...
Pomodliłem się do każdego boga jaki istniał bym był w wstanie wkurzyć tę kobietę do granic możliwości.