How to connect MySql database in java using eclipse?

Step1: Install Eclipse on your computer.
Step2: Download the Mysql database on your computer.
Refer to the below link to install the MySQL database and set configuration.
Step3: Download the JDBC jar file on your computer. If already download the jar file then discard this step. The below link for download JDBC connector jar file.
Step4: Now open the eclipse software and create a new project.
Step5: Then, create new a folder name an external_lib.
Step6: Now copy the JDBC jar file in the extracted folder. For example,

Step7: After pasting the driver, Add the building path. Please refer below screenshot.

Step8: After building that path, it creates a reference folder. so now we are configuring the path.

Step9: Just applies and close.

Step10: Then, create a class. And, give the below program.

 package DBProgram;
 import java.sql.Connection;
 import java.sql.DriverManager;
 public class DB {
 public static void main(String[] args) {
 try {
 Connection conn = DriverManager.getConnection(   "jdbc:mysql://localhost:3306/DB_name","user","passwd");
 System.out.println("Connected to the database test");
catch (Exception e) {




    Recent Posts

    Service Support

    Need our help to Learn or Post New Concepts Contact me