Error in JDBC Connection !
Hi
I'm simply trying to JDBC connect to mysql 5.5 from Net beans.
I'm trying to insert values from my java code in net beans to the table created in mysql.
Here is the error I'm getting:
"
java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost/midb? "
Where midb is the database name I have created in MySQL 5.5.
Here is the connection string I'm using under try block :
"
Connection conn = DriverManager.getConnection("jdbc:mysql//localhost/midb?"); "
AdditionalInformation:
Here is how I login to MySQL 5.5
I just need to enter my password and I can login easily.
Please help !
================================================== ================================================== ==
Here is the code I'm using:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javajdbc;
/**
*
* @
*/
import java.sql.*;
public class JavaJDBC {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql//localhost/midb?");
Statement st = conn.createStatement();
st.executeUpdate("INSERT INTO PERSONA VALUES('John','Jack','Stephen'");
}
catch (Exception e)
{
System.out.println(e);
}
}
}
Here is the actual errorshown in Net Beans:
run:
java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost/midb?
BUILD SUCCESSFUL (total time: 1 second)
Re: Error in JDBC Connection !
check your driver for mysql available in netbeans.
Re: Error in JDBC Connection !
If not in your web application libraries keep mysql-connector-java-xxxxx.jar file.
Re: Error in JDBC Connection !
You must download J connector:
MySQL :: Download Connector/J
Then you should unpack the downloaded filesomewhere you choose and look for a jar file named: mysql-connector-java-5.1.18-bin.jar. Remember where that file is located!
Then right click on your project (in which you want to use your sql queries) in netbeans, and go to the properties of the project.
In the properties choose the libraries tab and press the add jar file button. Select your mysql-connector-java-5.1.18-bin.jar file and add it.
Now it should work!