Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

JDBC

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Open Database Connectivity (ODBC) is an 

open standard application programming interface


(API) for accessing a database. By using ODBC statements in a program, you can access files in
a number of different databases, including Access, dBase, DB2, Excel, and Text. In addition to
the ODBC software, a separate module or driver is needed for each database to be accessed. The
main proponent and supplier of ODBC programming support is Microsoft.
ODBC is based on and closely aligned with The Open Group standard Structured Query
Language (SQL) Call-Level Interface. It allows programs to use SQL requests that will access
databases without having to know the proprietary interfaces to the databases. ODBC handles the
SQL request and converts it into a request the individual database system understands.
ODBC was created by the SQL Access Group and first released in September, 1992. Although
Microsoft Windows was the first to provide an ODBC product, versions now exist for UNIX,
OS/2, and Macintosh platforms as well.
In the newer distributed object architecture called Common Object Request Broker Architecture
(CORBA), the Persistent Object Service (POS) is a superset of both the Call-Level Interface and
ODBC. When writing programs in the Java language and using the Java Database Connectivity
(JDBC) application program interface, you can use a product that includes a JDBC-ODBC
"bridge" program to reach ODBC-accessible databases.

Drivers and Managers[edit]


Drivers[edit]
ODBC is based on the device driver model, where the driver encapsulates the logic needed to
convert a standard set of commands and functions into the specific calls required by the
underlying system. For instance, a printer driver presents a standard set of printing commands,
the API, to applications using the printing system. Calls made to those APIs are converted by the
driver into the format used by the actual hardware, say PostScript or PCL.
In the case of ODBC, the drivers encapsulate many functions that can be broken down into
several broad categories. One set of functions is primarily concerned with finding, connecting to
and disconnecting from the DBMS that driver talks to. A second set is used to send SQL
commands from the ODBC system to the DBMS, converting or interpreting any commands that
are not supported internally. For instance, a DBMS that does not support cursors can emulate this
functionality in the driver. Finally, another set of commands, mostly used internally, is used to
convert data from the DBMS's internal formats to a set of standardized ODBC formats, which
are based on the C language formats.
An ODBC driver enables an ODBC-compliant application to use a data source, normally a
DBMS. Some non-DBMS drivers exist, for such data sources as CSV files, by implementing a
small DBMS inside the driver itself. ODBC drivers exist for most DBMSs,
including Oracle, PostgreSQL, MySQL, Microsoft SQL Server (but not for the Compact aka CE
edition), Sybase ASE, SAP HANA[25][26] and DB2. Because different technologies have different
capabilities, most ODBC drivers do not implement all functionality defined in the ODBC
standard. Some drivers offer extra functionality not defined by the standard.
Driver Manager[edit]
Device drivers are normally enumerated, set up and managed by a separate Manager layer, which
may provide additional functionality. For instance, printing systems often include functionality
to provide spooling functionality on top of the drivers, providing print spooling for any
supported printer.
In ODBC the Driver Manager (DM) provides these features. [27] The DM can enumerate the
installed drivers and present this as a list, often in a GUI-based form.
But more important to the operation of the ODBC system is the DM's concept of a Data Source
Name (DSN). DSNs collect additional information needed to connect to a specific data source,
versus the DBMS itself. For instance, the same MySQL driver can be used to connect to any
MySQL server, but the connection information to connect to a local private server is different
from the information needed to connect to an internet-hosted public server. The DSN stores this
information in a standardized format, and the DM provides this to the driver during connection
requests. The DM also includes functionality to present a list of DSNs using human readable
names, and to select them at run-time to connect to different resources.
The DM also includes the ability to save partially complete DSN's, with code and logic to ask the
user for any missing information at runtime. For instance, a DSN can be created without a
required password. When an ODBC application attempts to connect to the DBMS using this
DSN, the system will pause and ask the user to provide the password before continuing. This
frees the application developer from having to create this sort of code, as well as having to know
which questions to ask. All of this is included in the driver and the DSNs.

Bridging configurations[edit]
A bridge is a special kind of driver: a driver that uses another driver-based technology.
ODBC-to-JDBC (ODBC-JDBC) bridges[edit]
An ODBC-JDBC bridge consists of an ODBC driver which uses the services of a JDBC driver to
connect to a database. This driver translates ODBC function-calls into JDBC method-calls.
Programmers usually use such a bridge when they lack an ODBC driver for some database but
have access to a JDBC driver. Example: SequeLink ODBC-JDBC Bridge
JDBC-to-ODBC (JDBC-ODBC) bridges[edit]
A JDBC-ODBC bridge consists of a JDBC driver which employs an ODBC driver to connect to
a target database. This driver translates JDBC method calls into ODBC function calls.
Programmers usually use such a bridge when a given database lacks a JDBC driver. Sun
Microsystems included one such bridge in the JVM, but viewed it as a stop-gap measure while
few JDBC drivers existed. Sun never intended its bridge for production environments, and
generally recommended against its use. As of 2008 independent data-access vendors deliver
JDBC-ODBC bridges which support current standards for both mechanisms, and which far
outperform the JVM built-in.[citation needed] Example: SequeLink JDBC-ODBC Bridge
The JDBC-ODBC bridge was dropped in Java 8.
OLE DB-to-ODBC bridges[edit]
An OLE DB-ODBC bridge consists of an OLE DB Provider which uses the services of an
ODBC driver to connect to a target database. This provider translates OLE DB method calls into
ODBC function calls. Programmers usually use such a bridge when a given database lacks an
OLE DB provider. Microsoft ships one, MSDASQL.DLL, as part of the MDAC system
component bundle, together with other database drivers, to simplify development in COM-aware
languages (e.g. Visual Basic). Third parties have also developed such, notably OpenLink
Software whose 64-bit OLE DB Provider for ODBC Data Sources filled the gap when Microsoft
initially deprecated this bridge for their 64-bit OS. [28] (Microsoft later relented, and 64-bit
Windows starting with Windows Server 2008 and Windows Vista SP1 have shipped with a 64-
bit version of MSDASQL.) Example: SequeLink OLEDB-ODBC Bridge
ADO.NET-to-ODBC bridges[edit]
An ADO.NET-ODBC bridge consists of an ADO.NET Provider which uses the services of an
ODBC driver to connect to a target database. This provider translates ADO.NET method calls
into ODBC function calls. Programmers usually use such a bridge when a given database lacks
an ADO.NET provider. Microsoft ships one as part of the MDAC system component bundle,
together with other database drivers, to simplify development in C#. Third parties have also
developed such. Example: SequeLink ADO.NET-ODBC Bridge

Open Database Connectivity (ODBC) is Microsoft's strategic interface for accessing data in a
heterogeneous environment of relational and non- relational database management systems.
Based on the Call Level Interface specification of the SQL Access Group, ODBC provides an
open, vendor- neutral way of accessing data stored in a variety of proprietary personal computer,
minicomputer, and mainframe databases. 

ODBC alleviates the need for independent software vendors and corporate developers to learn
multiple application programming interfaces. ODBC now provides a universal data access
interface. With ODBC, application developers can allow an application to concurrently access,
view, and modify data from multiple, diverse databases. 

ODBC is a core component of Microsoft Windows Open Services Architecture. Apple has
endorsed ODBC as a key enabling technology by announcing support into System 7 in the
future. With growing industry support, ODBC is quickly emerging as an important industry
standard for data access for both Windows and Macintosh applications.
ODBC is a specification to which developers write either: 

 An ODBC-enabled "front-end" or "client" desktop application, also known as an "ODBC


Client." This is the application that the computer-user sees on the computer screen. 

-or-
 An ODBC Driver for a "back-end" or "server" DBMS (Database Management System).
This is the DBMS application that resides on a computer that is used to store data for access by
several users. This application is not what is loaded on the end user's computer. This server
application is usually more robust (faster, with centralized security, and backups of data, and so
forth) than the client application. The ODBC Driver resides between the ODBC Client and the
DBMS; however, it is loaded on the front-end computer.
To use ODBC, the following three components are required: 

ODBC CLIENT - an ODBC-enabled front-end (also called ODBC client) - Examples: Microsoft
Access, an application created with Access, an application created with Microsoft Visual Basic,
an application created with C+Win SDK+ODBC SDK, or ODBC-enabled applications from
other vendors (such as Lotus). 

ODBC DRIVER - an ODBC Driver for the ODBC Server. The ODBC Driver Catalog contains
an extensive listing of ODBC Drivers. For example, the Microsoft ODBC Driver Pack is a
collection of seven ODBC Drivers ready to be used or bundled with ODBC clients. A SQL
Server ODBC Driver is included with Access, and Informix is working on an ODBC driver for
Informix. To obtain an ODBC Driver Catalog, call the Microsoft Order Desk at (800) 360-7561.
If you are outside the United States, contact your local subsidiary. To locate your subsidiary, see
the Microsoft World Wide Offices Web site at:
http://www.microsoft.com/worldwide/
Any ODBC client can access any DBMS for which there is an ODBC Driver. DBMS SERVER
is a back-end or server DBMS, for example SQL Server, Oracle, AS/400, Foxpro, Microsoft
Access, or any DBMS for which an ODBC driver exists.

How do these three components interact?


The ODBC client uses a language or vocabulary of commands (which is referred to as "ODBC")
to request data from, or to send data to, the back- end or server DBMS. However, the DBMS
doesn't understand the ODBC client request until the command passes through the ODBC Driver
for that specific DBMS. This ODBC driver is software that resides on the front-end. The ODBC
driver translates the command into a format that the ODBC Server can understand. The ODBC
Server sends the answer back to the ODBC Driver, which translates the answer into a format that
the ODBC Client can understand.

What's so great about ODBC?


First, application developers don't need to modify their applications to allow them to access data
from several back-ends. As long as there is an ODBC Driver for a particular back-end, an
ODBC-enabled front-end can access it. Second, one ODBC Driver for a particular DBMS allows
any ODBC-enabled application to be an ODBC client.

Examples of ODBC in Use

 Access front-end accessing data from a Oracle back-end using the Oracle ODBC Driver,
which ships with Access 1.1.
 Visual Basic front-end accessing data from a dBASE back-end using the dBASE ODBC
Driver, which is part of the MS ODBC Database Drivers Pack.
 C application written using C+ODBC SDK+Win SDK accessing data from an AS/400
using the AS/400 ODBC Driver available from Rochester Software.

Basic Questions and Answers

1. What is the ODBC SDK? 

The ODBC SDK is distributed on floppy disks, and contains about 150 pages of text that allows
a developer to write an ODBC-enabled Client or an ODBC Driver. The ODBC SDK is to be
used in conjunction with the Windows Software Developers Kit (SDK) and a C Compiler.
2. What is the ODBC Database Driver Pack? 

The ODBC Database Driver Pack is a collection of ODBC Drivers that is sold by Microsoft.
3. What is the ODBC Driver Catalog? 

The ODBC Driver Catalog contains descriptions of ODBC drivers developed by Microsoft and
other software companies. It contains an explanation of ODBC, and demonstrates industry
support for the standard.
4. What ODBC drivers are currently available? 

Dozens of ODBC drivers are currently available, including those for Microsoft SQL Server,
XLS, Text, xBase, Paradox, ODS, Oracle, RedISAM, FoxBase, Btrieve, Integra-SQL, DEC Rdb,
SQLBase, Informix, Ingres, DB2, SQL/DS, Teradata, and SQL/400.
5. How do I write an ODBC driver? 

To write an ODBC driver, use C+Win SDK+ODBC SDK.


6. What ODBC clients are currently available? 

From Microsoft: Access, Visual Basic, Foxpro+Connectivity Kit, Word 6.0 for Windows, Excel
5.0, MS Query Tool. 

From other vendors: PowerSoft, ObjectView, Lotus 1-2-3, Lotus Approach, Lotus Notes, Q+E,
and others.
7. How does one write an ODBC client? 

By using C+Win SDK+ODBC SDK, or by using Access, or by using Visual Basic, or by using
WinFox +Connectivity Kit, or by using one of the tools from other vendors designed to do this.
Difference Between JDBC ODBC

ODBC is an open interface which can be used by any application to communicate with any
database system, while JDBC is an interface that can be used by Java applications to access
databases. Therefore, unlike JDBC, ODBC is language independent. But by using JDBC-to-
ODBC bridge Java applications can also talk to any ODBC compliant database.

 Multithread: JDBC is multi-threaded - ODBC is not multi-threaded (at least


not thread safe)
 Flexibility: ODBC is a windows-specific technology - JDBC is specific to Java,
and is therefore supported on whatever OS supports Java
 Power: You can do everything with JDBC that you can do with ODBC, on any
platform.
 Language: ODBC is procedural and language independent - JDBC is object
oriented and language dependent (specific to java).
 Heavy load: JDBC is faster - ODBC is slower
 ODBC limitation: It is a relational API and can only work with data types that
can be expressed in rectangular or two-dimensional format. (it will not work with
data types like Oracle’s spatial data type)
 API: JDBC API is a natural Java Interface and is built on ODBC, and
therefore JDBC retains some of the basic feature of ODBC

ODBC vs JDBC
Typically, software applications are written in a specific programming language (such as Java,
C#, etc.), while databases accept queries in some other database specific language (such as SQL).
Therefore, when a software application needs to access data in a database, an interface that can
translate languages to each other (application and database) is required. Otherwise, application
programmers need to learn and incorporate database specific languages within their applications.
ODBC (Open Database Connectivity) and JDBC (Java DatabBase Connectivity) are two
interfaces that solve this specific problem. ODBC is a platform, language and operating system
independent interface that can be used for this purpose. Similarly, JDBC is a data API for the
Java programming language. Java programmers can use JDBC-to-ODBC bridge to talk to any
ODBC compliant database.
What is ODBC?
ODBC is an interface to access database management systems (DBMS). ODBC was developed
by SQL Access Group in 1992 at a time there were no standard medium to communicate
between a database and an application. It does not depend on a specific programming language
or a database system or an operating system. Programmers can use ODBC interface to write
applications that can query data from any database, regardless of the environment it is running on
or the type of DBMS it uses.
Because ODBC driver acts as a translator between the application and the database, ODBC is
able to achieve the language and platform independence. This means that the application is
relieved of the burden of knowing the database specific language. Instead it will only know and
use the ODBS syntax and the driver will translate the query to the database in a language it can
understand. Then, the results are returned in a format that can be understood by the application.
ODBC software API can be used with both relational and non relational database systems.
Another major advantage of having ODBC as a universal middleware between an application
and a database is that every time the database specification changes, the software does not need
to be updated. Only an update to the ODBC driver would be sufficient.
What is JDBC?
JDBC is a Data API developed for Java programming language. It was released with JDK 1.1 by
Sun Microsystems (Java’s initial owners). And its current version is JDBC 4.0 (currently
distributed with JAVA SE6). Java.sql and javax.sql packages contain the JDBC classes. It is an
interface that helps a client to access a database system, by providing methods to query and
update data in the databases. JDBC is more suitable for object oriented databases. You can
access any ODBC-compliant database by using the JDBC-to-ODBC bridge.
1.ODBC is for Microsoft and JDBC is for java applications.
2.ODBC can't be directly used with Java because it uses a C 
interface.
3.ODBC makes use of pointers which have been removed 
totally from java.
4.ODBC mixes simple and advanced features together and has 
complex options for simple queries,But JDBC is designed to 
keep things simple while allowing advanced capabilities 
when required.
5.ODBC requires manual installation of the ODBC driver 
manager and driver on all client machines.JDBC drivers are 
written in java and JDBC code is automatically 
installable,secure,and portable on all platforms.
6. JDBC API is a natural Java Interface and is built on 
ODBC. JDBC retains some of the basic feature of ODBC

Open Database Connectivity (also known as ODBC) is a function that provides a standard


software API method to those computers using database management systems (or DBMS). Its
designed was predicated on the idea of making a function independent of programming
languages, database systems and, operating systems.
Java Database Connectivity (also known as JDBC) is an API that is used specifically for
the Java programming language. It is used to define how a client may access a particular
database. It also provides methods for querying and updating data in that particular database. The
JDBC API is orientated specifically towards relational databases. Initially, the JDBC API was
introduced as a part of the Java 2 Platform, SE version 1.1. Coupled with a reference
implementation JDBC to ODBC bridge, this API was capable of enabling connections to any
ODBC accessible data source on the JVM host environment.

The implementations found on ODBCs are run through a plethora of operating systems. These
systems include, but are not limited to Microsoft Windows, Unix, Linux, and Mac OS X. There
are literally hundreds of drivers that exist of the ODBC variety –these include drivers for
enterprise DBMS (Oracle, DB2, Microsoft SQL Server, Sybase, IBM Lotus Domino, and
OpenLink Virtuoso). Some of these drivers are also found on desktop database products such as
FileMaker and Microsoft Access.
JDBC makes it possible for multiple implementations to exist and be used by the exact same
application for every implementation. This API offers a mechanism for dynamically loading the
necessary Java packages and registering those particular packages to the JDBC Driver Manager.
The Driver Manager is specifically used as a means to produce many connections –essentially,
acting as a connection factory– in order to create connections of the JDBC variety. These
connections support the creation and execution of statements. These statements have the ability
to be updated (statements such as the SQL statements CREATE, INSERT, UPDATE, and
DELETE). These statements may also be query statements (like the SELECT statement). Stored
procedures are able to be invoked through a JDBC connection. There are three specific classes in
which these statements may be represented in JDBC: Statement, PreparedStatement, and
CallableStatement. Statements that are considered update statements return an update count. This
count indicates how many rows were affected in the database. Query statements return a JDBC
row result set –meaning it is a statement that is invoked in order to walk over the result set.

Summary:
1. ODBC is a function that provides a standard software API method to computers using
DBMSs; JDBC is an API used for the Java programming language to define how a client may
access a database.

2. ODBC implementations are run through multiple operating systems; JDBC implementations
can exist and be used by the same application.
JDBC and ODBC are based on the X/Open SQL call-level interface standard. They provide an
Application Program Interface, or API, that allows the same program to access different
databases regardless of vendor ownership. Using standard Structured Query Language, or SQL,
statements, databases can be queried to either store, retrieve, delete or modify data.

JDBC is commonly used for object-oriented databases while ODBC is used to access Database
Management Systems, or DBMS. JDBC can only be used by applications written in Java,
whereas ODBC does not depend on the programming language, operating system and platform
of the program trying to access a database. This independence is achieved by the ODBC by
acting as translator between the database and application through a driver manager. JDBC can
only connect to ODBC-compliant databases by using a JDBC-to-ODBC bridge.

Some JDBC proponents suggest that JDBC is easier to learn compared to ODBC. Another
advantage of JDBC over ODBC is faster implementation on non-Windows applications.
1.ODBC is for Microsoft and JDBC is for java applications. 
2.ODBC can't be directly used with Java because it uses a C interface. 
3.ODBC makes use of pointers which have been removed totally from java. 
4.ODBC mixes simple and advanced features together and has complex options for 
simple queries, But JDBC is designed to keep things simple while allowing 
advanced capabilities when required. 
5.ODBC requires manual installation of the ODBC driver manager and driver on all 
client machines. JDBC drivers are written in java and JDBC code is automatically 
installable, secure, and portable on all platforms. 
6. JDBC API is a natural Java Interface and is built on ODBC. JDBC retains some 
of the basic feature of ODBC

You might also like