I am running a MySQL Community Server and receive the following error message:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/bedandbreakfast
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at SqlTest.main(SqlTest.java:19)
Here is my code:
I'm guessing it can't find the driver, but I'm not sure where to go from here. I have read JDBC Java trail and w3schools SQL tutorial, but am still stuck. Any help diagnosing what then wrong would be appreciated.
You are right, the error message means the DriverManager cannot find a suitable driver on the classpath that can handle requests for that particular JDBC URL.
There is usually no good reason to use the JDBC-ODBC bridge and plenty good reasons not to. Try using a type 4 driver instead. Have a look at that and remember there are thtree steps to getting a connection this way:
The driver files must be on the classpath
You must have called Class.forName with the correct class name (this step will register the driver with the DriverManager)
You must be using the correct syntax in your URL. The documentation for the driver will help here.