0% found this document useful (0 votes)
22 views

Is A Collection of Andasetof .: Dbms Interrelated Data Methods To Manipulate That Data Advantages of DBMS

DBMS is a collection of interrelated data and methods to manipulate that data. The most powerful DBMS are relational database management systems which store records in tables and define relationships among the tables. JDBC provides a way for Java programs to connect to a database and execute SQL statements. It uses drivers, the driver manager, and connections to establish this communication between Java programs and various database systems in a platform-independent way.

Uploaded by

rajagopald
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Is A Collection of Andasetof .: Dbms Interrelated Data Methods To Manipulate That Data Advantages of DBMS

DBMS is a collection of interrelated data and methods to manipulate that data. The most powerful DBMS are relational database management systems which store records in tables and define relationships among the tables. JDBC provides a way for Java programs to connect to a database and execute SQL statements. It uses drivers, the driver manager, and connections to establish this communication between Java programs and various database systems in a platform-independent way.

Uploaded by

rajagopald
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

DBMS is a collection of interrelated

data and a set of methods to manipulate


that data.
data

Advantages of DBMS
• Reduces redundancy
• Avoids inconsistency
• Allows to share data
• Concurrency control
• Data integrity
Most powerful DBMS are Relational
Data Base Management Systems.

Relational Database is a special


type of database that stores records
in tables and defines relationships
among the data tables.
Different DBMS vendors selects different
data storage and data access methods.

SQL is used as Industry Standardized


Query Language to access and modify
Relational DBMS.

ODBC is the bridge between RDBMS


and other Front ends .( ODBC is full of
pointers of C- language)
JDBC is
* Set of Classes and Interfaces used to
develop client/server Database programs
using Java.
* API that allows a Java Application,
Applet or Servlet to communicate with
the DB server using SQL commands.
* Package that lets Java programs
connect to DB, query it, update it using
industry standard Query Language.
* Programs developed using JDBC
can access Universal Databases.
Databases
* Programs developed using JDBC are
platform/vendor independent.
independent
* Java programs can talk to any
random Relational Database using
JDBC.
* JDBC provides cross-platform,
cross-database access to databases
from Java programs
Two-tier Model
Application
CLIENT Machine
JDBC
code

Database server
DBMS
Three-tier Model

Java applet CLIENT Machine

Http,RMI,CORBA...

Application Server machine/Web server


Server(java)
(business logic)
JDBC
Database server
DBMS
JDBC components
• Application
• JDBC DriverManager
• Drivers
• DataBaseManagementSystem
Application can
• Requests a connection with a
database
• Sends SQL staments to database
• Defines storage areas and datatypes
for result sets
• Requests results
• Processes errors
• Controls transactions and closes
connection.
Driver Manager can
• Locate a driver for a particular
database.

• Process JDBC initialization calls.

• Perform parameter validation for

JDBC calls.
Driver can
• Establish a connection to database
• Sends requests to database.
• Return results to user Application
• Perform translations when required
by the user application
• Format errors.
1JDBC ODBC Bridge

Application

JDBC ODBC Driver Java

ODBC Driver Non-Java


Proprietary Database protocol

Database
JDBC-ODBC bridge driver, converts JDBC calls to ODBC calls
2. Native API as basic

Application

JDBC Driver Java

Native Driver Non-Java


Proprietary Database protocol

Database
This driver forwards calls to a locally installed library, usually
developed in C language and provided by the database vendor.
3. JDBC-Net-All- Java Driver
Application Client
JDBC Driver(Client)
JDBC Driver n/w protocol
Java
JDBC Driver(server)
Native Driver Server
Database
All layers necessary to communicate with database are implemented
in java and are fully portable because they do not use local libraries
or native code.
4. Native protocol-All java driver

Application
JDBC Driver Java

DB protocols built in java

Database
This driver is platform independent because it is purely written
in Java. This driver is specific to the database.
Java Application

JDBC Manager ( Driver Manager )


JDBC JDBC-ODBC
JDBC Driver JDBC Driver
net Driver Bridge

ODBC
Native Driver
Driver

Native
Driver

DataBase DataBase DataBase DataBase


Data Source

It consists the information about the

server, which the user application


wants to access.
Steps to work with JDBC

•Load Drivers and Register


•Establish connection to the database
•Create SQL statements
•Execute the statements
•Retrieve the results
•close the statement and connection
Important Classes of JDBC API
(All the classes are in java.sql.* package)
• DriverManager
• Connection
• Statement
• PreparedStatement
• CallableStatement
• ResultSet
• ResultSetMetaData
• DatabaseMetaData
Steps to write JDBC programs
1. Load the specific driver class into the
program using the method
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”)

2. Create an object of Connection(path) class


using getConnection() method of
DriverManager Class
Connection c= DriverManager.getConnection
(“jdbc:odbc:dsn”,”usrname”,”passwd”)
Session is maintainedby connection object.
Steps to write JDBC programs
3. Create a Statement Object using
createStatement() method of Connection class
Statement st=c.createStatement()
Statement object carries data between client/server
4. Execute Queries using executeXXX()
methods of Statement class and capture
result in ResultSet class object.
ResultSet rs= st.executeXXX (“SQL stmt”)
5. Using ResultSet object display the result
of the executed query.
Prepared Statement Characteristics
•Compiled Only once
•Stored in Server
•Can be executed with Different value
•Reduces the network traffic
•These are sent to DB prior to their
execution.
•They do not remain in DB after the
resources associated with them are
freed.
Prepared Statements
•Prepared statements are used to
execute dynamic SQL statements.
•A dynamic SQL statement is a
statement where some of the values
are not known at the time of creating
the statement.
Prepared Statements

PreparedStatement ps=
con.prepareStatement
(“Select * from emp where dept=?”);

ps.setXXX(int index, DataType Val);

ps.executeQuery();

You might also like