SeminarTopics.co.in

Java Database Connectivity


Published on Aug 15, 2016

Abstract

JDBCT is a JavaT API for executing SQL statements. (As a point of interest, JDBC is a trademarked name and is not an acronym; nevertheless, JDBC is often thought of as standing for "Java Database Connectivity".)

It consists of a set of classes and interfaces written in the Java programming language. JDBC provides a standard API for tool/database developers and makes it possible to write database applications using a pure Java API.

Using JDBC, it is easy to send SQL statements to virtually any relational database. In other words, with the JDBC API, it isn't necessary to write one program to access a Sybase database, another program to access an Oracle database, another program to access an Informix database, and so on. One can write a single program using the JDBC API, and the program will be able to send SQL statements to the appropriate database. And, with an application written in the Java programming language, one also doesn't have to worry about writing different applications to run on different platforms. The combination of Java and JDBC lets a programmer write it once and run it anywhere

Introduction of Java Database Connectivity

Java, being robust, secure, easy to use, easy to understand, and automatically Downloadable on a network, is an excellent language basis for database applications. What is needed is a way for Java applications to talk to a variety of different databases. JDBC is the mechanism for doing this. JDBC extends what can be done in Java. For example, with Java and the JDBC API, it is possible to publish a web page containing an applet that uses information obtained from a remote database. Or an enterprise can use JDBC to connect all its employees (even if they are using a conglomeration of Windows, Macintosh, and UNIX machines) to one or more internal databases via an intranet.

With more and more programmers using the Java programming language, the need for easy database access from Java is continuing to grow. MIS managers like the combination of Java and JDBC because it makes disseminating information easy and economical. Businesses can continue to use their installed databases and access information easily even if it is stored on different database management systems. Development time for new applications is short. Installation and version control are greatly simplified.

What Does JDBC Do?

Simply put, JDBC makes it possible to do three things:

1. establish a connection with a database

2. send SQL statements

3. process the results.

The following code fragment gives a basic example of these three steps:

Connection con = DriverManager.getConnection (

"jdbc:odbc:wombat", "login", "password");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");

while (rs.next()) {

int x = getInt("a");

String s = getString("b");

float f = getFloat("c");

}

JavaSoft provides three JDBC product components as part of the Java Developer's Kit (JDK):

. the JDBC driver manager,

. the JDBC driver test suite, and

. the JDBC-ODBC bridge.

The JDBC driver manager is the backbone of the JDB architecture. It actually is quite small and simple; its primary function is to connect Java applications to the correct JDBC driver and then get out of the way