how to connect java application with mysql database(wamp) server

In this tutorial shows how to connect java application with mysql database/wamp server and how to insert data into the database using the java application.

A video tutorial for connect java application with mysql database(wamp) server

Step 01 Create java project and database

Step 02 Add “Mysql.jdbc.driver” to java project library

Do you need help to remotely set up my any project on your machine or customize any project with your requirement please contact  syntech1994@gmail.com

Step 03 Create database connection class to connect java application with mysql database(wamp) server

import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
/**
 *
 * @author SynTech
 */
public class DBConnect {
public static Connection connect()
     {
         Connection con=null;
         try {
             Class.forName("com.mysql.jdbc.Driver");
             con=DriverManager.getConnection("jdbc:mysql://localhost:3306/YourDatabaseName?","yourDatabaseUsername","YourdatabasePassword");
             JOptionPane.showMessageDialog(null, "connection success");   
 } catch (Exception e) {
        System.out.println("inter.DBConnect.connect()");
    }
   return con;
}
}

Follow video tutorial with this source code.

The technologies used in this tutorial

  • Java: All codes have been written using the java programming language.
  • MySql: MySql has used as a database for this project.
  • Netbeans: This project has developed inside of the Netbeans IDE.

Check more projects>>

Be the first to comment

Leave a Reply

Your email address will not be published.


*