import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String a=t1.getText();
{try {
String driver = "com.mysql.jdbc.Driver";
Class.forName(driver);
Connection C=DriverManager.getConnection("jdbc:mysql://localhost:3306/ab","root","root");
Statement S=C.createStatement();
String query="Insert into ab values('"+a+"');";
S.executeUpdate(query);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
} }
}
I have given the correct address but it is showing the no driver found.I'm using the mysql-connector-C-6.1. It is in my build path. I have restarted MySQL. I've also logged on from the command line with root and Password and it connected fine. I'm not currently seeing a port 3306 in STATUS.