No suitable driver found for jdbc: mysql: // localhost: 3306 / database

advertisements

I'm using NetBeans to learn how to use sql in Java. However, I get that error even though I'm doing everything right. Here is my connection statement:

connection = DriverManager.getConnection("jbdc:mysql://localhost:3306/database",
    "root", "MsqJ449?");

Also, I added the mysql-connector-java-5.1.31-bin.jar to my Compile Time and Run Time libraries under Properties in NetBeans. That database exists in MySQL. What else could the problem be?


You need to load the driver, by calling:

Class.forName("com.mysql.jdbc.Driver");

at some point before you use it.