I am making a standalone database application in which I use netbeans for java and a mysql database as my server.
Inserting basic values into my database tables fails with an exception "no jdbc driver found for jdbc:mysql:\localhost\basicinfo" where in basicinfo is my database name with "info" as my database table. My code:
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.swing.JOptionPane;
public class class1
{
public static void main(String[] args )
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql:\\localhost\basicinfo","root","root");
Statement stmt=(Statement)con.createStatement();
String name="Jerome Dcruz";
String contactno="9773523568";
String insert="INSERT INTO info VALUES('"+name+"','"+contactno+"');";
stmt.executeUpdate(insert);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage() ,"Error", 1);
}
}
}