Loading

Introduction to JDBC

  • JDBC: Java to Database Connectivity / Connection.
  • JDBC is a software or API used to connect databases on Java applications.
  • Sun Microsystems has developed JDBC software as part of J2SE.  

Simple Structure of JDBC


Steps to start the JDBC project

Steps:

  1. Download and install MySQL software.
  2. Download MySQL connection Jar files.
  3. Open Eclipse or any IDE to create a Java project.
  4. Create Java build path: Right click ---> properties ---> libraries ---> add external jar file(MySQL-connector-Java) ---> apply and close.
  5. Create a new package and class.

Java database connectivity with MySQL

  • To connect Java applications with MySQL database we need to follow five steps:

Steps:

  1. Load and Register Driver class.
  2. Establish a connection between the Java application and MySQL database.
  3. Prepare SQL statement.
  4. Execute statement.
  5. Close connection.

What is a Driver and Driver Manager?

  • A driver is used to translate Java to database specific language. It is dependent on a database, for each database, there is a separate Driver.
  • Driver Manager is used to establish connections between Java applications to databases, and it is independent.