Transcript Slide 1
DATABASE
CONNECTIVITY
TO MYSQL
To Connect to a relational database from
within Java Application, can be done using
JDBC API of Java. It mainly do the
following tasks.
1. Establish a connection with a database.
2. Send SQL statements to database
server.
3. Process the result obtained.
Classes Used for Database
Connectivity
Four main classes in the JDBC API that are
generally used for database connectivity.
1. DriverManager Class
2. Connection Class
3. Statement Class
4. ResultSet Class
Prerequisites for connecting to
MySQL from Java
MySQL provides connectivity for
client applications developed in
the Java programming language
via a JDBC driver, which is called
MySQL Connector/J
To check the availability
• Start NetBeans IDE
• Click Tools
Libraries
• In the Library box, look for MySQL JDBC
driver under the class Libraries.
• Note down its path
Steps for creating database
connectivity applications
• Import the packages required for database
programming
• Register the JDBC driver
• Open a connection
• Execute a Query
• Extract Data from the Result set
• Clean up the environment