0% found this document useful (0 votes)
66 views25 pages

Database Connectivity To Mysql

(1) A Java application needs to connect to a database like MySQL to manipulate stored data. (2) JDBC provides an interface for Java applications to connect to databases. It establishes connections, sends SQL queries, and returns results. (3) The main JDBC classes are DriverManager, Connection, Statement, and ResultSet which handle connecting to databases, executing queries, and processing results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views25 pages

Database Connectivity To Mysql

(1) A Java application needs to connect to a database like MySQL to manipulate stored data. (2) JDBC provides an interface for Java applications to connect to databases. It establishes connections, sends SQL queries, and returns results. (3) The main JDBC classes are DriverManager, Connection, Statement, and ResultSet which handle connecting to databases, executing queries, and processing results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy