Skip navigation links

MySQL Forums :: Connector/JDBC and Java :: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver


Advanced Search

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Posted by: ssentamu ddumba ()
Date: November 06, 2012 05:08AM

try {
Connection connection;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("jdbc:mysql://localhost/javadatabase","root","");
System.out.println("Testing system");
String sql = "insert into test_data values(?,?,?,?)";
PreparedStatement pst = connection.prepareStatement(sql);
System.out.println("Testing two");

pst.setString(1,txt_fnum.getText());
pst.setString(2,txt_snum.getText());
pst.setString(3,txt_result.getText());
pst.executeUpdate();
} catch(Exception e){
System.err.println(e);
System.exit(1);
}

When I run the code above it gives me an error

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

What should I do to solve that error

Options: ReplyQuote


Subject Written By Posted
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver ssentamu ddumba 11/06/2012 05:08AM
Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Todd Farmer 11/21/2012 10:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.