Presentation is loading. Please wait.

Presentation is loading. Please wait.

DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.

Similar presentations


Presentation on theme: "DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of."— Presentation transcript:

1 DATABASE CONNECTIVITY TO MYSQL

2 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.

3 =>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).

4

5 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.

6 =>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.

7 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.

8 => 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.

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25


Download ppt "DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of."

Similar presentations


Ads by Google