Introduction-to-JDBC
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:
- Download and install MySQL software.
- Download MySQL connection Jar files.
- Open Eclipse or any IDE to create a Java project.
- Create Java build path: Right click ---> properties ---> libraries ---> add external jar file(MySQL-connector-Java) ---> apply and close.
- 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:
- Load and Register Driver class.
- Establish a connection between the Java application and MySQL database.
- Prepare SQL statement.
- Execute statement.
- 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.