Results 1 to 4 of 4
Thread: Error in JDBC Connection !
- 11-03-2011, 09:27 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 76
- Rep Power
- 0
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)
- 11-04-2011, 11:30 PM #2
Member
- Join Date
- Aug 2011
- Posts
- 54
- Rep Power
- 0
Re: Error in JDBC Connection !
check your driver for mysql available in netbeans.
- 11-04-2011, 11:33 PM #3
Member
- Join Date
- Aug 2011
- Posts
- 54
- Rep Power
- 0
Re: Error in JDBC Connection !
If not in your web application libraries keep mysql-connector-java-xxxxx.jar file.
- 11-29-2011, 10:14 PM #4
Member
- Join Date
- Nov 2011
- Posts
- 1
- Rep Power
- 0
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!
Similar Threads
-
protocol violation error in jdbc connection
By ronbigman in forum JDBCReplies: 0Last Post: 05-03-2011, 08:58 AM -
Help! JDBC Connection Error
By pryncipe in forum New To JavaReplies: 5Last Post: 03-19-2011, 04:03 PM -
JDBC connection to Cache - error
By javavick in forum New To JavaReplies: 1Last Post: 05-06-2010, 02:06 PM -
Error creating JDBC connection in Eclipse
By tascoa in forum EclipseReplies: 2Last Post: 11-06-2009, 10:20 AM -
Help me this error in JDBC-ODBC connection
By lordelf in forum Java ServletReplies: 3Last Post: 04-04-2009, 08:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks