Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
JDBC 2

JDBC 2

Ratings:

5.0

(1)
|Views: 62 |Likes:
Published by api-3749401

More info:

Published by: api-3749401 on Oct 16, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Database
1
To create a Table use the following Command: CREATE TABLE employees
(id int, name varchar2 (25), salary int)
2
To delete a Table use: DROP TABLE employees
3
To insert new records: INSERT INTO employees (1,\u2019Hello\u2019,6000)
4
To delete rows: DELETE FROM employees WHERE salary>1000
5
To select from the table: SELECT * from employees;
6

To retrieve data from the table based on a condition: SELECT * from employees WHERE salary >5000 ORDER BY salary DESC (Whether descending or ascending), name.

7
To Modify data: UPDATE employees SET salary=7000 WHERE ID=1

The following are the basic SQL Statements
- DML: Data Manipulation Language - insert, update, delete commands
- DDL: Data Definition Language \u2013 create (table, procedure, function),

drop, truncate.
- DCL: Data Control Language \u2013 grant, invoke.
History:
- The X/Open and SQL Access Group defined the Call Level Interface

(CLI).
- CLI is a library of function calls that supports SQL Statements.
- JDBC is also CLI
- The most important benefit for programmers using the ODBC or JDBC

CLI is the interoperability.
- All clients adhere to a standard programming interface.
- ODBC is Microsoft\u2019s implementation of a CLI.
- It allows the programmer to develop, compile and deploy an application

without targeting a specific Database.

- The ODBC interface defines a library of function calls that allow an application to connect to a DB, execute SQL statements and retrieve results.

JDBC
JDBC does the following things:

a) establish connection with a database
b) send SQL statements
c) processes the results

-
We have to import java.sql package
-
Almost all the classes throw SQLException and hence have to be put in a try and
catch block.
-
JDBC is an interface to relational data source.
-
JDBC is the interface between the database and java end user application, servlet applet.
-

JDBC library provides the means for executing SQL statement to access and operate on a relational database. JDBC Library is a set of classes and interfaces that provide a uniform API for access to a broad range of databases.

-

First of all before connection to a database, we need to have the Driver for that Database. A Driver is an interface / Bridge between 2 objects, for example between the hardware and software.

-

It is the duty of the Driver to read, store or retrieve data from the back end. The Driver reads data from the Database and converts it into a known format. So we have different drivers for different databases.

-
SQL is a language used to create, manipulate, examine, and manage relational databases.
-

Because SQL is an application-specific language, a single statement can be very expressive and can initiate high-level actions, such as sorting and merging data. SQL was standardized in 1992 so that a program could communicate with most database systems without having to change the SQL commands.

-
Unfortunately, you must connect to a database before sending SQL commands, and each
database vendor has a different interface, as well as different extensions of SQL.
-
Enter ODBC. Microsoft brought about the concept of ODBC, which is preinstalled on all
Windows OS. That is why we can create a DSN directly.
-
Sun\u2019s JDBC driver reads from the in-built ODBC Driver. One of the fundamental principals of
JDBC\u2019s design was to make it practical to built JDBC drivers based on other database APIs.
-
The advantage of the JDBC \u2013 ODBC Bridge is that there is no need for separate Database
Configuration, no need for separate installation and only follow the standard SQL syntax.
-
The Limitation of the JDBC \u2013 ODBC Bridge is that it can run only on Windows OS and Solaris
OS.
JDBC Driver Models
a) Two Tier Model

In this model, the java applet / application interact directly with the database. A JDBC driver is required to communicate with the particular database management system that is being accessed. The SQL statements are sent to the database and the results are given to the user. This type of model is referred to as the client / server configuration where user is the client and the machine that has the database is called the server.

Three Tier Model
The reason for the middle tier (Application Server) is and it does the following

a) Collection of SQL statements from the client and handing over the same to the DB
b) Receiving results from the DB to the client
c) Maintaining control over accessing and updating of the data.

Middle tier until recently had been written in C and C++ which enable faster performance. With the introduction of optimizing compilers that translate java byte codes into machine specific code, it is not possible to implement the middle tier in java.

There are 4 types of JDBC Drivers and they are:
JDBC-ODBC Bridge Driver:
-
This driver (sun.jdbc.odbc.JdbcOdbcDriver) is included with the JDK to enable java
applications to access data through drivers written to the ODBC standard.
-
This Driver Bridge is very useful for accessing data in data sources for which no pure JDBC
drives exist.
-
This bridge works by translating the JDBC methods into ODBC function calls and has the
advantage of working with a huge number of ODBC Drivers.
Native API / Partly Java Driver
-
This class of Driver consist of Java Code that access data through native methods \u2013 typically
calls to a particular vendor library.
-
This class of Driver is very convenient when a C data access library already exists, but it is
not usually very portable
-

This driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix and other DBMS. But some binary code has to be loaded on all clients like the bridge driver and again not suitable for large applications.

Net Protocol All Java Client
-
This class of Drivers is implemented as \u201cmiddleware\u201d with the client driver completely
implemented in Java.
-
This client driver communicates with a separate middleware component (usually TCP/IP),
which translates JDBC requests into database access calls.

Activity (5)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Lance liked this
deepraj81 liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->