Steps:
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.
https://www.whereisstuff.com/2020/02/how-to-install-mysql-database-and-set.html
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.
https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-8.0.19.zip
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,
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.
https://www.whereisstuff.com/2020/02/how-to-install-mysql-database-and-set.html
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.
https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-8.0.19.zip
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,
Step8: After building that path, it creates a reference folder. so now we are configuring the path.
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) {
System.out.println(e);
}
}
}
Output:
No comments:
Post a Comment