To connect with database first install the xampp then create the database and table according to me.
Code of connection with database.
public class Connect {
Connection con = null;
public static Connection dbConnect(){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/exam", "root","");
return con;
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
return null;
}
}
}
Be First to Comment