Netbeans – How To Load Jdbc Driver To Connect To Mysql Database (Java)
Netbeans – How To Load Jdbc Driver To Connect To Mysql Database (Java)
To download jdbc mysql driver go to – https://dev.mysql.com/downloads/connector/j/

To connect to mysql database using netbeans you need a database connector called MySQL Connector/J.
You need to add mysql connector jar file to the current project so that you can interact with the target database.
To import the connector to the current project:
Step 1. Right click on project.

Step 2. Select Properties.
Step 3. Select Libraries.
Step 4. Click “add external jars”.

Step 5. Go to the folder where you have downloaded the file. Select MySQL Connector/J jar file and click ok.

After you select mysql connector j, it’s going to be added under compile time libraries section.

Now when you go back to the project you will see connector j jar file on libraries section.

To check whether the connector has been added to the project use the code below.
package checkmysqlconnector; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Genuine */ public class CheckMysqlConnector { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here String forName = "com.mysql.cj.jdbc.Driver"; try { Class.forName(forName); System.out.println("Driver Loaded Successfully"); } catch (ClassNotFoundException ex) { System.out.println("Driver Failed To Load Successfully"); System.out.println(ex.getMessage()); } } }