In this tutorial, we will see how to connect MySQL Database in Eclipse IDE.
Connect MySQL Database in Eclipse:
Eclipse is a most familiar opensource IDE for J2EE developers; it provides essential tools to help developers to manage their applications.
Here we will see the most useful use case; how to connect MySQL Database in Eclipse.
- Eclipse IDE for Enterprise Java Developers
- Version: 2019-03 (4.11.0)
- Build id: 20190314-1200
- MySQL 8.0.15
- Windows 10 64 Bit
1. Goto Database Perspective:
Window-> Perspective->Open Perspective-> Other
2. Select Database Development Perspective:
select the Database Development perspective and click on the Open button.
It opens the Data Base development perspective as below.
3. Create Database Connections:
There you can see the Database Connections folder, right click and click on the New.
Then you will see the New Connection Profile window as below; there you will find all available connections, filter the connection profile type with “MySQL” string and select the MySQL connection.
Name this connection as MYSQL_DB_CONNECTION and click on Next button.
This window allows you to attach the driver details to connect with the MySQL DB. Click on the below-highlighted icon to attach MySQL connector.
Then you will see the following window; select the MySQL version which you wanted to connect with and move to JAR List tab.
Here we have to attach the MySQL connector.
4. Download and attach MySQL connector:
Download the MySQL connector from the official website.
It will be downloaded as a .zip file; extract the zip and there you will see the mysql-connector-java-xxx.jar; add this jar file in Jar List tab by clicking on the Add JAR button as below screenshot and click on the Ok button.
Specify the MySQL connection details like username, password and database name and click on the Test Connection button.
If everything configured well, you would see the below Ping succeeded! Message.
Then Click on the Finish button.
Again go to Data Source Explorer and refresh on Database Connections folder and expand the folders inside it. You would see the MySQL database schema here.
Happy Learning 🙂