This post guide to connect java application with mysql(Wamp) database. You can watch full video tutorial. That's include step by step activity to connect. All codes regarding this tutorial include
in this post and also you can download this project files.
To connect Java application with the MySQL database, we need to follow some steps.
1 : Driver class add to library(com.mysql.jdbc.Driver).
2 : Create database connection.
3 : Write connection class.
This is connection class.
package inter;
import java.lang.*;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
/**
*
* @author Ruwan
*/
public class DBConnect {
public static Connection connect()
{
Connection con=null;
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/inventorycontrol?","root","");
// JOptionPane.showConfirmDialog(null,"connect to data base");
} catch (Exception e) {
System.out.println("inter.DBConnect.connect()");
JOptionPane.showConfirmDialog(null,e);
}
return con;
}
}
You can download connection file and watch video tutorial how connect java application with Mysql server.
No comments:
Post a Comment