0
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.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Mayank Jindal
  • 35
  • 2
  • 7

1 Answers1

0

Are you sure you are using the connector-c? That one is, as the name suggests, for the C language and not for java. You should be using the connector-j library.

Jiří
  • 13
  • 4