Download DATABASE CONNECTIVITY TO MYSQL

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

DBase wikipedia , lookup

Serializability wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

IMDb wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Btrieve wikipedia , lookup

Microsoft Access wikipedia , lookup

Oracle Database wikipedia , lookup

Ingres (database) wikipedia , lookup

Functional Database Model wikipedia , lookup

SQL wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Concurrency control wikipedia , lookup

Database wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

PL/SQL wikipedia , lookup

Relational model wikipedia , lookup

Versant Object Database wikipedia , lookup

Database model wikipedia , lookup

Clusterpoint wikipedia , lookup

ContactPoint wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Transcript
DATABASE CONNECTIVITY TO MYSQL
Introduction
=>A real life application needs to manipulate data
stored in a Database.
=>A database is a collection of related data in the form
of Tables. Most of the database uses SQL
(Structured Query Language) to Insert, Delete,
Update or retrieve stored data.
=>In order to connect a Java application to a database
designed in MySQL, Oracle, Sybase, MS SQL Server
etc, you need a Bridge/Interface Driver Program.
=>Java Provides JDBC (Java Database Connection)
and JDBC-ODBC interface/ Driver to connect a
database. JDBC is commonly used to connect
MySQL database.
=>What is JDBC ?
 JDBC is JAVA’s Database connection driver
interface which performs the following task
for the application.
(1).Establish a connection with a Database.
(2).Send SQL request (Query) to a Database
Server.
(3.Returns Result obtained against Query.
Some RDBMS like MS Access requires
ODBC (Open Database Connection), which
can be connect through JDBC-ODBC
driver(jdbc.odbcbridge).
Classes used for Database Connectivity
The Core element of JDBC is JDBC API, which consists
of a set of Java classes equipped with predefined
methods to handle various data access functions such
as Selecting appropriate database driver, establishing
connection, submitting SQL query and processing
results.
 There are four main classes in the JDBC.
 1.Driver Manager Class : The JDBC Driver Manager
Class Loads the JDBC driver needed to access a
particular data source, locates & logs on to the
database & returns a Connection Objects.
 2.Connection Class : The JDBC Connection class
manages the communications between a java client
application & a specific database (e.g. MYSQL
database), including passing SQL statement to the
DBMS & managing transactions.
=>3.Statement Class : The JDBC Statement
class contains SQL string that are submitted
to the DBMS .An SQL Select statement
returns a result Set object that contains the
data retreived as the result of SQL statement.
=>4.Result set class: The JDBC Result Set
class provides predefined methods to access,
analyze,& convert data values returned by an
executed SQL select statement.
 A JDBC driver must be registered with JDBC
Driver Manage using Class.forName() method
before establishing a connection.
CONNECTIVITY TO MYSQL FROM JAVA
Steps for creating Database Connectivity
Applications
There are mainly six steps :
Step1: Import the packages Required for
Database Programming.
Step2: Register the JDBC Driver to JDBC
Driver manager
Step3: Open a connection
Step4: Execute a Query
Step5: Extract Data From Result set
Step6: Close Connection.
=> Connection: A connection(represented
through connection object) is the session
between the application program and the
database .to do anything with database,
one must have a connection object.
=>Result Set: A Result set (represent by a
Result Set Object) refers to a logical set of
records that are fetched from the database
by executing a query and made avalible to
the application-program.