JDBC tutorials

Home arrow Java Tutorials arrow Tips arrow JDBC tutorials
JDBC tutorials Print E-mail
Contributed by Joe   
Tuesday, 08 August 2006

Database Connectivity Overview  

 Databases use a common language called Structured Query Language (SQL) to manipulate data stored in tables. During the early days of database use, SQL wasn't standardized; but in 1992, a body came together and standardized how SQL should be represented and used. Although this standardization is helpful for the manipulation of data, it doesn't do anything for the connection to the database from an application

To help make connectivity as portable as possible, a new interface was created: Open Database Connectivity (ODBC). ODBC is a C-based API that exposes a common framework for connecting to a database. A database vendor that wants to provide access using ODBC writes a bridge driver hooking the API to the vendor's database. The bridge driver is different for each specific database vendor.

ODBC has served the C and C++ community well, but it doesn't help the Java community. Java Database Connectivity (JDBC) is an answer to ODBC, and by using it, Java applications can connect to databases in a portable fashion

JDBC Overview

The JDBC API is the industry standard for database-independent connectivity between the Java programming language and a wide range of databases. The JDBC API provides a call-level API for SQL-based database access. JDBC technology allows you to use the Java programming language to exploit "Write Once, Run Anywhere" capabilities for applications that require access to enterprise data.

With JDBC,Java programs will be able to connect to databases anywhere on the network and to query data from the database with the simple syntax that database programmers have been using for yearsSQL. 

JDBC Architecture

Type 1: JDBC-ODBC Bridge plus ODBC Driver

This combination provides JDBC access via ODBC drivers. ODBC binary code -- and in many cases, database client code -- must be loaded on each client machine that uses a JDBC-ODBC Bridge. Sun provides a JDBC-ODBC Bridge driver, which is appropriate for experimental use and for situations in which no other driver is available.

Type 2: A native API partly Java technology-enabled driver

This type of driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS. Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine.

Type 3: Pure Java Driver for Database Middleware

This style of driver translates JDBC calls into the middleware vendor's protocol, which is then translated to a DBMS protocol by a middleware server. The middleware provides connectivity to many different databases.

Type 4: Direct-to-Database Pure Java Driver

This style of driver converts JDBC calls into the network protocol used directly by DBMSs, allowing a direct call from the client machine to the DBMS server and providing a practical solution for intranet access.

Three basic JDBC operations:

  • First, establishing and tearing down connections to your database server
  • Second, querying data
  • Finally, reading up the results of that query
A JDBC  example

Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(jdbc:mysql://192.168.1.1/products?user=spider&password=spider");

Last Updated ( Tuesday, 26 September 2006 )

  home              contact us

 

©2006-2009 DeveloperZone.biz   All rights reserved     powered by Mambo Designed by Siteground