You are on page 1of 7

Connecting Netbeans with MySQL Database

programmatically

To connect NetBeans with MySQL Database:


1. Launch NetBeans IDE application
2. Click on File> New Project> Select Java from categories> Java Application from Projects> click
on Next button
Connecting Netbeans with MySQL Database
programmatically

3. Enter your project name and click on Finish button in our case we have taken college as the
project name
Connecting Netbeans with MySQL Database
programmatically

4. After successful creation of the project following files will be generated that you will be able to
see in the project explorer
Connecting Netbeans with MySQL Database
programmatically

Click and open College.java


file located under
college>Source
Packages>college and add
the following NetBeans
database connection code in
the place of “// TODO code
application logic here” (you
can remove this line):

6.Press Shift+F6 or click on


Run > Run file to execute the
programme
7.After execution, you may
encounter
“com.mysql.jdbc.Driver” error
which is caused by the
missing
com.mysql.jdbc.Driver
How to fix com.mysql.jdbc.DriverBUILD SUCCESSFUL and
add MySQL JDBC Driver Jar file?

To fix com.mysql.jdbc.DriverBUILD SUCCESSFUL and add MySQL JDBC Driver Jar file:
Right-click on Libraries and select Add Library option
How to fix com.mysql.jdbc.DriverBUILD SUCCESSFUL and
add MySQL JDBC Driver Jar file?

In the Add Library window select MySQL JDBC Driver and click on Add Library button
How to fix com.mysql.jdbc.DriverBUILD SUCCESSFUL and
add MySQL JDBC Driver Jar file?

After adding the MySQL JDBC Driver, run the program, and after successful execution, you will be
able to see the results in the Output screen as follows:

You might also like